mirror of
https://github.com/kbparagua/paloma
synced 2023-03-27 23:21:17 -04:00
ActionControllerExtension
This commit is contained in:
parent
2856fc62e2
commit
010b250089
60 changed files with 112 additions and 1908 deletions
|
@ -1,14 +0,0 @@
|
|||
(function(){
|
||||
// Initializes the main container for all filters and skippers for this
|
||||
// specific scope.
|
||||
var filter = new Paloma.FilterScope(':scope');
|
||||
|
||||
// The _x object is also available on callbacks.
|
||||
// You can make a variable visible on callbacks by using _x here.
|
||||
//
|
||||
// Example:
|
||||
// _x.visibleOnCallback = "I'm a shared variable"
|
||||
var _x = Paloma.variableContainer;
|
||||
|
||||
// ~> Start definitions here and remove this line.
|
||||
})();
|
|
@ -1,13 +0,0 @@
|
|||
(function(){
|
||||
// Initializes locals container for the global scope.
|
||||
// All _locals.js file will inherit all locals here by default.
|
||||
//
|
||||
// Define a local by adding property to 'locals'.
|
||||
//
|
||||
// Example:
|
||||
// locals.localMethod = function(){};
|
||||
var locals = Paloma.locals['/'] = {};
|
||||
|
||||
|
||||
// ~> Start local definitions here and remove this line.
|
||||
})();
|
|
@ -1,19 +0,0 @@
|
|||
(function(){
|
||||
// Initializes callbacks container for the this specific scope.
|
||||
Paloma.callbacks[':controller_path'] = {};
|
||||
|
||||
// Initializes locals container for this specific scope.
|
||||
// Define a local by adding property to 'locals'.
|
||||
//
|
||||
// Example:
|
||||
// locals.localMethod = function(){};
|
||||
var locals = Paloma.locals[':controller_path'] = {};
|
||||
|
||||
|
||||
// ~> Start local definitions here and remove this line.
|
||||
|
||||
|
||||
// Remove this line if you don't want to inherit locals defined
|
||||
// on parent's _locals.js
|
||||
Paloma.inheritLocals({from : ':parent', to : ':controller_path'});
|
||||
})();
|
|
@ -1,3 +0,0 @@
|
|||
//= require ./_locals.js
|
||||
//= require ./_filters.js
|
||||
//= require_tree .
|
|
@ -1,23 +0,0 @@
|
|||
(function(){
|
||||
// You access variables from before/around filters from _x object.
|
||||
// You can also share variables to after/around filters through _x object.
|
||||
var _x = Paloma.variableContainer;
|
||||
|
||||
// We are using _L as an alias for the locals container.
|
||||
// Use either of the two to access locals from other scopes.
|
||||
//
|
||||
// Example:
|
||||
// _L.otherController.localVariable = 100;
|
||||
var _L = Paloma.locals;
|
||||
|
||||
// Access locals for the current scope through the _l object.
|
||||
//
|
||||
// Example:
|
||||
// _l.localMethod();
|
||||
var _l = _L[':controller_path'];
|
||||
|
||||
|
||||
Paloma.callbacks[':controller_path'][':action'] = function(params){
|
||||
// Do something here.
|
||||
};
|
||||
})();
|
|
@ -1,3 +0,0 @@
|
|||
//= require paloma_core.js
|
||||
//= require ./_locals.js
|
||||
//= require ./_filters.js
|
|
@ -1,16 +0,0 @@
|
|||
(function(){
|
||||
// Initializes locals container for this specific scope.
|
||||
// Define a local by adding property to 'locals'.
|
||||
//
|
||||
// Example:
|
||||
// locals.localMethod = function(){};
|
||||
var locals = Paloma.locals[':namespace'] = {};
|
||||
|
||||
|
||||
// ~> Start local definitions here and remove this line.
|
||||
|
||||
|
||||
// Remove this line if you don't want to inherit locals defined
|
||||
// on parent's _locals.js
|
||||
Paloma.inheritLocals({from : '/', to : ':namespace'});
|
||||
})();
|
|
@ -1,3 +0,0 @@
|
|||
//= require ./_locals.js
|
||||
//= require ./_filters.js
|
||||
//= require ./:controller/_manifest.js
|
|
@ -1,30 +0,0 @@
|
|||
<% id = "#{Time.now.to_i}#{(rand * 1000).ceil}" %>
|
||||
|
||||
<div class="paloma-callback-details" data-id="<%= id %>">
|
||||
<script type="text/javascript">
|
||||
/*
|
||||
(function(){
|
||||
|
||||
// Do not continue if Paloma.js is not found.
|
||||
if (window['Paloma'] === undefined && window['console'] !== undefined){
|
||||
console.warn("Paloma.js not found. Require it in your application.js.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Remove any callback details if any
|
||||
$('.paloma-callback-details[data-id!=' + <%= id %> + ']').remove();
|
||||
|
||||
var run = function(){
|
||||
var callbacks = <%= callbacks.to_json.html_safe %>;
|
||||
|
||||
for (var i = 0, len = callbacks.length; i < len; i++){
|
||||
Paloma.execute(callbacks[i]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$(document).ready(function(){ run(); });
|
||||
})();
|
||||
*/
|
||||
</script>
|
||||
</div>
|
33
app/views/paloma/_hook.html.erb
Normal file
33
app/views/paloma/_hook.html.erb
Normal file
|
@ -0,0 +1,33 @@
|
|||
<% id = "#{Time.now.to_i}#{(rand * 1000).ceil}" %>
|
||||
|
||||
<div class="js-paloma-hook" data-id="<%= id %>">
|
||||
<script type="text/javascript">
|
||||
(function(){
|
||||
|
||||
// Do not continue if Paloma not found.
|
||||
if (window['Paloma'] === undefined && window['console'] !== undefined){
|
||||
console.warn("Paloma not found. Require it in your application.js.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Remove any callback details if any
|
||||
$('.js-paloma-hook[data-id!=' + <%= id %> + ']').remove();
|
||||
|
||||
var requests = <%= requests.to_json.html_safe %>;
|
||||
|
||||
for (var i = 0, len = requests.length; i < len; i++){
|
||||
var request = requests[i];
|
||||
|
||||
Paloma.engine.requests.push({
|
||||
resource: request['resource'],
|
||||
action: request['action'],
|
||||
params: request['params']
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function(){ Paloma.engine.start(); });
|
||||
|
||||
})();
|
||||
</script>
|
||||
</div>
|
|
@ -1,30 +1,11 @@
|
|||
module Paloma
|
||||
mattr_accessor :destination, :templates
|
||||
|
||||
def self.root
|
||||
@paloma_root ||= "#{File.dirname(__FILE__)}/../"
|
||||
end
|
||||
|
||||
|
||||
def self.index_js
|
||||
@index_js ||= "#{Paloma.destination}/index.js"
|
||||
end
|
||||
|
||||
|
||||
def self.destination
|
||||
@destination ||= 'app/assets/javascripts/paloma'
|
||||
end
|
||||
|
||||
|
||||
def self.templates
|
||||
@templates ||= "#{Paloma.root}/app/templates"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# TODO: Rails version checking
|
||||
|
||||
require 'action_controller/railtie'
|
||||
|
||||
require 'paloma/action_controller_extension'
|
||||
require 'paloma/rails/engine'
|
||||
|
|
|
@ -1,22 +1,16 @@
|
|||
module Paloma
|
||||
|
||||
# TODO explain!
|
||||
module ::ActionController::Flash
|
||||
alias_method :original_redirect_to, :redirect_to
|
||||
end
|
||||
|
||||
|
||||
|
||||
module ActionControllerExtension
|
||||
|
||||
def self.included base
|
||||
base.send :include, InstanceMethods
|
||||
|
||||
base.module_eval do
|
||||
prepend_view_path "#{Paloma.root}/app/views/"
|
||||
|
||||
# Enable paloma on all controller action by default
|
||||
before_filter :js
|
||||
|
||||
after_filter :update_callback, :if => :html_response_from_render?
|
||||
before_filter :track_paloma_request
|
||||
after_filter :append_paloma_hook, :if => :html_response_from_render?
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -24,117 +18,68 @@ module Paloma
|
|||
|
||||
|
||||
|
||||
protected
|
||||
module InstanceMethods
|
||||
|
||||
|
||||
|
||||
# Save
|
||||
def redirect_js_hook options = {}, response_status_and_flash = {}
|
||||
push_current_callback
|
||||
original_redirect_to options, response_status_and_flash
|
||||
end
|
||||
alias_method :redirect_to, :redirect_js_hook
|
||||
|
||||
|
||||
#
|
||||
# js false
|
||||
# js :new, :params => {}
|
||||
# js :resource => 'Namespace.Resource', :action => 'testAction', :params => {}
|
||||
# js :params => {}
|
||||
#
|
||||
def js options = {}, extras = {}
|
||||
# default resource
|
||||
resource_name = controller_path.split('/').map(&:titleize).join('.')
|
||||
callback = {:resource => resource_name, :action => self.parse_action, :params => {}}
|
||||
|
||||
if options.is_a? Hash
|
||||
callback = options if options[:resource].present? && options[:action].present?
|
||||
|
||||
elsif options.is_a? Symbol
|
||||
callback[:action] = self.parse_action(options)
|
||||
|
||||
elsif options.is_a? FalseClass
|
||||
callback = nil
|
||||
#
|
||||
# Use on controllers to pass variables to Paloma controller.
|
||||
#
|
||||
def js params = {}
|
||||
@paloma_params = params
|
||||
end
|
||||
|
||||
# Include rails request details
|
||||
if callback.present?
|
||||
controller_detail = controller_path.split('/')
|
||||
callback[:params][:rails] = {:controller => controller_detail.pop,
|
||||
:namespace => controller_detail.pop,
|
||||
:action => self.action_name,
|
||||
:controllerPath => self.controller_path}
|
||||
|
||||
#
|
||||
# Executed every time a controller action is executed.
|
||||
#
|
||||
# Keeps track of what Rails controller/action is executed
|
||||
# and their corresponding Paloma parameters.
|
||||
#
|
||||
def track_paloma_request
|
||||
puts 'Tracking Request'
|
||||
resource = controller_path.split('/').map(&:titleize).join('.')
|
||||
|
||||
paloma_request = {:resource => resource,
|
||||
:action => self.action_name,
|
||||
:params => @paloma_params}
|
||||
|
||||
session[:paloma_requests] ||= []
|
||||
session[:paloma_requests].push paloma_request
|
||||
end
|
||||
|
||||
self.current_callback = callback
|
||||
|
||||
#
|
||||
# Before rendering html reponses,
|
||||
# this is exectued to append Paloma's html hook to the response.
|
||||
#
|
||||
# The html hook contains the javascript code that
|
||||
# will execute the tracked Paloma requests.
|
||||
#
|
||||
def append_paloma_hook
|
||||
hook = view_context.render(
|
||||
:partial => 'paloma/hook',
|
||||
:locals => {:requests => session[:paloma_requests]})
|
||||
|
||||
before_body_end_index = response_body[0].rindex('</body>')
|
||||
|
||||
# Append the hook after the body tag if it is present.
|
||||
if before_body_end_index.present?
|
||||
before_body = response_body[0][0, before_body_end_index].html_safe
|
||||
after_body = response_body[0][before_body_end_index..-1].html_safe
|
||||
|
||||
response.body = before_body + hook + after_body
|
||||
else
|
||||
# If body tag is not present, append hook in the response body
|
||||
response.body += hook
|
||||
end
|
||||
|
||||
session[:paloma_requests] = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def html_response_from_render?
|
||||
[nil, 'text/html'].include?(response.content_type) && self.status != 302
|
||||
end
|
||||
|
||||
|
||||
def update_callback
|
||||
return clear_callbacks if self.current_callback.nil?
|
||||
|
||||
push_current_callback
|
||||
|
||||
paloma_txt = view_context.render(
|
||||
:partial => "paloma/callback_hook",
|
||||
:locals => {:callbacks => self.callbacks})
|
||||
|
||||
|
||||
before_body_end_index = response_body[0].rindex('</body>')
|
||||
|
||||
if before_body_end_index.present?
|
||||
before_body_end_content = response_body[0][0, before_body_end_index].html_safe
|
||||
after_body_end_content = response_body[0][before_body_end_index..-1].html_safe
|
||||
|
||||
response_body[0] = before_body_end_content + paloma_txt + after_body_end_content
|
||||
|
||||
response.body = response_body[0]
|
||||
else
|
||||
# If body tag is not present, append paloma_txt in the response body
|
||||
response_body[0] += paloma_txt
|
||||
response.body = response_body[0]
|
||||
end
|
||||
|
||||
clear_callbacks
|
||||
end
|
||||
|
||||
|
||||
def push_current_callback
|
||||
session[:callbacks] ||= []
|
||||
session[:callbacks].push(self.current_callback) if self.current_callback.present?
|
||||
end
|
||||
|
||||
|
||||
def callbacks
|
||||
session[:callbacks]
|
||||
end
|
||||
|
||||
|
||||
def clear_callbacks
|
||||
session[:callbacks] = []
|
||||
end
|
||||
|
||||
|
||||
def current_callback= callback
|
||||
@__paloma_callback__ = callback
|
||||
end
|
||||
|
||||
|
||||
def current_callback
|
||||
@__paloma_callback__
|
||||
end
|
||||
|
||||
|
||||
def parse_action action = nil
|
||||
action ||= self.action_name
|
||||
action.camelize(:lower)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
15
spec/test_app/.gitignore
vendored
15
spec/test_app/.gitignore
vendored
|
@ -1,15 +0,0 @@
|
|||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
#
|
||||
# If you find yourself ignoring temporary files generated by your text editor
|
||||
# or operating system, you probably want to add a global ignore instead:
|
||||
# git config --global core.excludesfile ~/.gitignore_global
|
||||
|
||||
# Ignore bundler config
|
||||
/.bundle
|
||||
|
||||
# Ignore the default SQLite database.
|
||||
/db/*.sqlite3
|
||||
|
||||
# Ignore all logfiles and tempfiles.
|
||||
/log/*.log
|
||||
/tmp
|
|
@ -1 +0,0 @@
|
|||
--color
|
|
@ -1,5 +0,0 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'selenium-webdriver'
|
||||
|
||||
gemspec :path => '../../'
|
|
@ -1,261 +0,0 @@
|
|||
== Welcome to Rails
|
||||
|
||||
Rails is a web-application framework that includes everything needed to create
|
||||
database-backed web applications according to the Model-View-Control pattern.
|
||||
|
||||
This pattern splits the view (also called the presentation) into "dumb"
|
||||
templates that are primarily responsible for inserting pre-built data in between
|
||||
HTML tags. The model contains the "smart" domain objects (such as Account,
|
||||
Product, Person, Post) that holds all the business logic and knows how to
|
||||
persist themselves to a database. The controller handles the incoming requests
|
||||
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
||||
and directing data to the view.
|
||||
|
||||
In Rails, the model is handled by what's called an object-relational mapping
|
||||
layer entitled Active Record. This layer allows you to present the data from
|
||||
database rows as objects and embellish these data objects with business logic
|
||||
methods. You can read more about Active Record in
|
||||
link:files/vendor/rails/activerecord/README.html.
|
||||
|
||||
The controller and view are handled by the Action Pack, which handles both
|
||||
layers by its two parts: Action View and Action Controller. These two layers
|
||||
are bundled in a single package due to their heavy interdependence. This is
|
||||
unlike the relationship between the Active Record and Action Pack that is much
|
||||
more separate. Each of these packages can be used independently outside of
|
||||
Rails. You can read more about Action Pack in
|
||||
link:files/vendor/rails/actionpack/README.html.
|
||||
|
||||
|
||||
== Getting Started
|
||||
|
||||
1. At the command prompt, create a new Rails application:
|
||||
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
||||
|
||||
2. Change directory to <tt>myapp</tt> and start the web server:
|
||||
<tt>cd myapp; rails server</tt> (run with --help for options)
|
||||
|
||||
3. Go to http://localhost:3000/ and you'll see:
|
||||
"Welcome aboard: You're riding Ruby on Rails!"
|
||||
|
||||
4. Follow the guidelines to start developing your application. You can find
|
||||
the following resources handy:
|
||||
|
||||
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
||||
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
||||
|
||||
|
||||
== Debugging Rails
|
||||
|
||||
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
||||
will help you debug it and get it back on the rails.
|
||||
|
||||
First area to check is the application log files. Have "tail -f" commands
|
||||
running on the server.log and development.log. Rails will automatically display
|
||||
debugging and runtime information to these files. Debugging info will also be
|
||||
shown in the browser on requests from 127.0.0.1.
|
||||
|
||||
You can also log your own messages directly into the log file from your code
|
||||
using the Ruby logger class from inside your controllers. Example:
|
||||
|
||||
class WeblogController < ActionController::Base
|
||||
def destroy
|
||||
@weblog = Weblog.find(params[:id])
|
||||
@weblog.destroy
|
||||
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
||||
end
|
||||
end
|
||||
|
||||
The result will be a message in your log file along the lines of:
|
||||
|
||||
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
||||
|
||||
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
||||
|
||||
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
||||
several books available online as well:
|
||||
|
||||
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
||||
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
||||
|
||||
These two books will bring you up to speed on the Ruby language and also on
|
||||
programming in general.
|
||||
|
||||
|
||||
== Debugger
|
||||
|
||||
Debugger support is available through the debugger command when you start your
|
||||
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
||||
execution at any point in the code, investigate and change the model, and then,
|
||||
resume execution! You need to install ruby-debug to run the server in debugging
|
||||
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
||||
|
||||
class WeblogController < ActionController::Base
|
||||
def index
|
||||
@posts = Post.all
|
||||
debugger
|
||||
end
|
||||
end
|
||||
|
||||
So the controller will accept the action, run the first line, then present you
|
||||
with a IRB prompt in the server window. Here you can do things like:
|
||||
|
||||
>> @posts.inspect
|
||||
=> "[#<Post:0x14a6be8
|
||||
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
||||
#<Post:0x14a6620
|
||||
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
||||
>> @posts.first.title = "hello from a debugger"
|
||||
=> "hello from a debugger"
|
||||
|
||||
...and even better, you can examine how your runtime objects actually work:
|
||||
|
||||
>> f = @posts.first
|
||||
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
||||
>> f.
|
||||
Display all 152 possibilities? (y or n)
|
||||
|
||||
Finally, when you're ready to resume execution, you can enter "cont".
|
||||
|
||||
|
||||
== Console
|
||||
|
||||
The console is a Ruby shell, which allows you to interact with your
|
||||
application's domain model. Here you'll have all parts of the application
|
||||
configured, just like it is when the application is running. You can inspect
|
||||
domain models, change values, and save to the database. Starting the script
|
||||
without arguments will launch it in the development environment.
|
||||
|
||||
To start the console, run <tt>rails console</tt> from the application
|
||||
directory.
|
||||
|
||||
Options:
|
||||
|
||||
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
||||
made to the database.
|
||||
* Passing an environment name as an argument will load the corresponding
|
||||
environment. Example: <tt>rails console production</tt>.
|
||||
|
||||
To reload your controllers and models after launching the console run
|
||||
<tt>reload!</tt>
|
||||
|
||||
More information about irb can be found at:
|
||||
link:http://www.rubycentral.org/pickaxe/irb.html
|
||||
|
||||
|
||||
== dbconsole
|
||||
|
||||
You can go to the command line of your database directly through <tt>rails
|
||||
dbconsole</tt>. You would be connected to the database with the credentials
|
||||
defined in database.yml. Starting the script without arguments will connect you
|
||||
to the development database. Passing an argument will connect you to a different
|
||||
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
||||
PostgreSQL and SQLite 3.
|
||||
|
||||
== Description of Contents
|
||||
|
||||
The default directory structure of a generated Ruby on Rails application:
|
||||
|
||||
|-- app
|
||||
| |-- assets
|
||||
| |-- images
|
||||
| |-- javascripts
|
||||
| `-- stylesheets
|
||||
| |-- controllers
|
||||
| |-- helpers
|
||||
| |-- mailers
|
||||
| |-- models
|
||||
| `-- views
|
||||
| `-- layouts
|
||||
|-- config
|
||||
| |-- environments
|
||||
| |-- initializers
|
||||
| `-- locales
|
||||
|-- db
|
||||
|-- doc
|
||||
|-- lib
|
||||
| `-- tasks
|
||||
|-- log
|
||||
|-- public
|
||||
|-- script
|
||||
|-- test
|
||||
| |-- fixtures
|
||||
| |-- functional
|
||||
| |-- integration
|
||||
| |-- performance
|
||||
| `-- unit
|
||||
|-- tmp
|
||||
| |-- cache
|
||||
| |-- pids
|
||||
| |-- sessions
|
||||
| `-- sockets
|
||||
`-- vendor
|
||||
|-- assets
|
||||
`-- stylesheets
|
||||
`-- plugins
|
||||
|
||||
app
|
||||
Holds all the code that's specific to this particular application.
|
||||
|
||||
app/assets
|
||||
Contains subdirectories for images, stylesheets, and JavaScript files.
|
||||
|
||||
app/controllers
|
||||
Holds controllers that should be named like weblogs_controller.rb for
|
||||
automated URL mapping. All controllers should descend from
|
||||
ApplicationController which itself descends from ActionController::Base.
|
||||
|
||||
app/models
|
||||
Holds models that should be named like post.rb. Models descend from
|
||||
ActiveRecord::Base by default.
|
||||
|
||||
app/views
|
||||
Holds the template files for the view that should be named like
|
||||
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
||||
eRuby syntax by default.
|
||||
|
||||
app/views/layouts
|
||||
Holds the template files for layouts to be used with views. This models the
|
||||
common header/footer method of wrapping views. In your views, define a layout
|
||||
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
||||
Inside default.html.erb, call <% yield %> to render the view using this
|
||||
layout.
|
||||
|
||||
app/helpers
|
||||
Holds view helpers that should be named like weblogs_helper.rb. These are
|
||||
generated for you automatically when using generators for controllers.
|
||||
Helpers can be used to wrap functionality for your views into methods.
|
||||
|
||||
config
|
||||
Configuration files for the Rails environment, the routing map, the database,
|
||||
and other dependencies.
|
||||
|
||||
db
|
||||
Contains the database schema in schema.rb. db/migrate contains all the
|
||||
sequence of Migrations for your schema.
|
||||
|
||||
doc
|
||||
This directory is where your application documentation will be stored when
|
||||
generated using <tt>rake doc:app</tt>
|
||||
|
||||
lib
|
||||
Application specific libraries. Basically, any kind of custom code that
|
||||
doesn't belong under controllers, models, or helpers. This directory is in
|
||||
the load path.
|
||||
|
||||
public
|
||||
The directory available for the web server. Also contains the dispatchers and the
|
||||
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
||||
server.
|
||||
|
||||
script
|
||||
Helper scripts for automation and generation.
|
||||
|
||||
test
|
||||
Unit and functional tests along with fixtures. When using the rails generate
|
||||
command, template test files will be generated for you and placed in this
|
||||
directory.
|
||||
|
||||
vendor
|
||||
External libraries that the application depends on. Also includes the plugins
|
||||
subdirectory. If the app has frozen rails, those gems also go here, under
|
||||
vendor/rails/. This directory is in the load path.
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/env rake
|
||||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||
|
||||
require File.expand_path('../config/application', __FILE__)
|
||||
require 'rspec/core/rake_task'
|
||||
|
||||
RSpec::Core::RakeTask.new('spec:generators') do |spec|
|
||||
spec.pattern = FileList['spec/generators/*_spec.rb']
|
||||
end
|
||||
|
||||
RSpec::Core::RakeTask.new('spec:javascripts') do |spec|
|
||||
spec.pattern = FileList['spec/javascripts/*_spec.rb']
|
||||
end
|
||||
|
||||
TestApp::Application.load_tasks
|
|
@ -1,16 +0,0 @@
|
|||
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||
// listed below.
|
||||
//
|
||||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
||||
//
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
||||
// GO AFTER THE REQUIRES BELOW.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require paloma
|
||||
//= require_tree .
|
|
@ -1,9 +0,0 @@
|
|||
(function(){
|
||||
|
||||
var self = Paloma.Resource.create('Foo');
|
||||
|
||||
self.prototype.basicAction = function(params){
|
||||
console.log(params);
|
||||
};
|
||||
|
||||
})();
|
|
@ -1,2 +0,0 @@
|
|||
//= require paloma.js
|
||||
//= require_tree .
|
|
@ -1,3 +0,0 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
class BarController < ApplicationController
|
||||
def basic_action
|
||||
render :inline => '<h1>Bar! Basic Action</h1>', :layout => 'application'
|
||||
end
|
||||
|
||||
|
||||
def another_basic_action
|
||||
render :inline => '<h1>Bar! Another Basic Action</h1>', :layout => 'application'
|
||||
end
|
||||
|
||||
|
||||
def yet_another_basic_action
|
||||
render :inline => '<h1>Bar! Yet Another Basic Action</h1>', :layout => 'application'
|
||||
end
|
||||
|
||||
|
||||
def different_params
|
||||
js :params => {
|
||||
:boolean => true,
|
||||
:array => [1, 2, 3],
|
||||
:string => 'Banana',
|
||||
:integer => 69,
|
||||
:float => 3.1416,
|
||||
:hash => {:a => 'Hello', :b => 'World'}}
|
||||
|
||||
render :inline => '<h1>Bar! Different Params</h1>', :layout => 'application'
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
class FooController < ApplicationController
|
||||
def basic_action
|
||||
render :inline => '<h1>Foo! Basic Action</h1>', :layout => 'application'
|
||||
end
|
||||
|
||||
def callback_from_another_action
|
||||
js :basic_action
|
||||
render :inline => '<h1>Foo! Callback From Another Action</h1>', :layout => 'application'
|
||||
end
|
||||
|
||||
def callback_from_another_controller
|
||||
js :controller => 'bar', :action => 'basic_action'
|
||||
render :inline => '<h1>Foo! Callback From Another Controller</h1>', :layout => 'application'
|
||||
end
|
||||
|
||||
def skip_callback
|
||||
js false
|
||||
render :inline => '<h1>Foo! Skip Callback</h1>', :layout => 'application'
|
||||
end
|
||||
|
||||
def callback_from_namespaced_controller
|
||||
js :controller => 'sample_namespace/baz', :action => 'basic_action'
|
||||
render :inline => '<h1>Foo! Callback From Namespaced Controller</h1>', :layout => 'application'
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
module SampleNamespace
|
||||
class BazController < ApplicationController
|
||||
def basic_action
|
||||
render :inline => 'SampleNamespace/Baz! Basic Action', :layout => 'application'
|
||||
end
|
||||
|
||||
|
||||
def another_basic_action
|
||||
render :inline => 'SampleNamespace/Baz! Another Basic Action', :layout => 'application'
|
||||
end
|
||||
|
||||
|
||||
def yet_another_basic_action
|
||||
render :inline => 'SampleNamespace/Baz! Yet Another Basic Action', :layout => 'application'
|
||||
end
|
||||
|
||||
|
||||
def callback_from_another_action
|
||||
js :basic_action
|
||||
render :inline => '<h1>Baz! Callback From Another action</h1>', :layout => 'application'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Paloma</title>
|
||||
<%= csrf_meta_tags %>
|
||||
<%= javascript_include_tag "application" %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
|
@ -1,4 +0,0 @@
|
|||
# This file is used by Rack-based servers to start the application.
|
||||
|
||||
require ::File.expand_path('../config/environment', __FILE__)
|
||||
run TestApp::Application
|
|
@ -1,74 +0,0 @@
|
|||
require File.expand_path('../boot', __FILE__)
|
||||
|
||||
# Pick the frameworks you want:
|
||||
# require "active_record/railtie"
|
||||
require "action_controller/railtie"
|
||||
require "action_mailer/railtie"
|
||||
require "active_resource/railtie"
|
||||
require "sprockets/railtie"
|
||||
require "rails/test_unit/railtie"
|
||||
|
||||
|
||||
# Issue: Sprockets cannot find jquery
|
||||
# Solution: http://www.ruby-forum.com/topic/2484569
|
||||
require "jquery-rails"
|
||||
|
||||
|
||||
if defined?(Bundler)
|
||||
# If you precompile assets before deploying to production, use this line
|
||||
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
||||
# If you want your assets lazily compiled in production, use this line
|
||||
# Bundler.require(:default, :assets, Rails.env)
|
||||
end
|
||||
|
||||
module TestApp
|
||||
class Application < Rails::Application
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Application configuration should go into files in config/initializers
|
||||
# -- all .rb files in that directory are automatically loaded.
|
||||
|
||||
# Custom directories with classes and modules you want to be autoloadable.
|
||||
# config.autoload_paths += %W(#{config.root}/extras)
|
||||
|
||||
# Only load the plugins named here, in the order given (default is alphabetical).
|
||||
# :all can be used as a placeholder for all plugins not explicitly named.
|
||||
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
||||
|
||||
# Activate observers that should always be running.
|
||||
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
||||
|
||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||
# config.time_zone = 'Central Time (US & Canada)'
|
||||
|
||||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
||||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||
# config.i18n.default_locale = :de
|
||||
|
||||
# Configure the default encoding used in templates for Ruby 1.9.
|
||||
config.encoding = "utf-8"
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
config.filter_parameters += [:password]
|
||||
|
||||
# Enable escaping HTML in JSON.
|
||||
config.active_support.escape_html_entities_in_json = true
|
||||
|
||||
# Use SQL instead of Active Record's schema dumper when creating the database.
|
||||
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
||||
# like if you have constraints or database-specific column types
|
||||
# config.active_record.schema_format = :sql
|
||||
|
||||
# Enforce whitelist mode for mass assignment.
|
||||
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
||||
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
||||
# parameters by using an attr_accessible or attr_protected declaration.
|
||||
# config.active_record.whitelist_attributes = true
|
||||
|
||||
# Enable the asset pipeline
|
||||
config.assets.enabled = true
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets
|
||||
config.assets.version = '1.0'
|
||||
end
|
||||
end
|
|
@ -1,6 +0,0 @@
|
|||
require 'rubygems'
|
||||
|
||||
# Set up gems listed in the Gemfile.
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||
|
||||
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
|
@ -1,5 +0,0 @@
|
|||
# Load the rails application
|
||||
require File.expand_path('../application', __FILE__)
|
||||
|
||||
# Initialize the rails application
|
||||
TestApp::Application.initialize!
|
|
@ -1,31 +0,0 @@
|
|||
TestApp::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
# In the development environment your application's code is reloaded on
|
||||
# every request. This slows down response time but is perfect for development
|
||||
# since you don't have to restart the web server when you make code changes.
|
||||
config.cache_classes = false
|
||||
|
||||
# Log error messages when you accidentally call methods on nil.
|
||||
config.whiny_nils = true
|
||||
|
||||
# Show full error reports and disable caching
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
# Don't care if the mailer can't send
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Print deprecation notices to the Rails logger
|
||||
config.active_support.deprecation = :log
|
||||
|
||||
# Only use best-standards-support built into browsers
|
||||
config.action_dispatch.best_standards_support = :builtin
|
||||
|
||||
|
||||
# Do not compress assets
|
||||
config.assets.compress = false
|
||||
|
||||
# Expands the lines which load the assets
|
||||
config.assets.debug = true
|
||||
end
|
|
@ -1,64 +0,0 @@
|
|||
TestApp::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
# Code is not reloaded between requests
|
||||
config.cache_classes = true
|
||||
|
||||
# Full error reports are disabled and caching is turned on
|
||||
config.consider_all_requests_local = false
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
# Disable Rails's static asset server (Apache or nginx will already do this)
|
||||
config.serve_static_assets = false
|
||||
|
||||
# Compress JavaScripts and CSS
|
||||
config.assets.compress = true
|
||||
|
||||
# Don't fallback to assets pipeline if a precompiled asset is missed
|
||||
config.assets.compile = false
|
||||
|
||||
# Generate digests for assets URLs
|
||||
config.assets.digest = true
|
||||
|
||||
# Defaults to nil and saved in location specified by config.assets.prefix
|
||||
# config.assets.manifest = YOUR_PATH
|
||||
|
||||
# Specifies the header that your server uses for sending files
|
||||
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
||||
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
# config.force_ssl = true
|
||||
|
||||
# See everything in the log (default is :info)
|
||||
# config.log_level = :debug
|
||||
|
||||
# Prepend all log lines with the following tags
|
||||
# config.log_tags = [ :subdomain, :uuid ]
|
||||
|
||||
# Use a different logger for distributed setups
|
||||
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
||||
|
||||
# Use a different cache store in production
|
||||
# config.cache_store = :mem_cache_store
|
||||
|
||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
||||
# config.action_controller.asset_host = "http://assets.example.com"
|
||||
|
||||
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
||||
# config.assets.precompile += %w( search.js )
|
||||
|
||||
# Disable delivery errors, bad email addresses will be ignored
|
||||
# config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Enable threaded mode
|
||||
# config.threadsafe!
|
||||
|
||||
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
||||
# the I18n.default_locale when a translation can not be found)
|
||||
config.i18n.fallbacks = true
|
||||
|
||||
# Send deprecation notices to registered listeners
|
||||
config.active_support.deprecation = :notify
|
||||
|
||||
end
|
|
@ -1,35 +0,0 @@
|
|||
TestApp::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
# The test environment is used exclusively to run your application's
|
||||
# test suite. You never need to work with it otherwise. Remember that
|
||||
# your test database is "scratch space" for the test suite and is wiped
|
||||
# and recreated between test runs. Don't rely on the data there!
|
||||
config.cache_classes = true
|
||||
|
||||
# Configure static asset server for tests with Cache-Control for performance
|
||||
config.serve_static_assets = true
|
||||
config.static_cache_control = "public, max-age=3600"
|
||||
|
||||
# Log error messages when you accidentally call methods on nil
|
||||
config.whiny_nils = true
|
||||
|
||||
# Show full error reports and disable caching
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
# Raise exceptions instead of rendering exception templates
|
||||
config.action_dispatch.show_exceptions = false
|
||||
|
||||
# Disable request forgery protection in test environment
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
|
||||
# Tell Action Mailer not to deliver emails to the real world.
|
||||
# The :test delivery method accumulates sent emails in the
|
||||
# ActionMailer::Base.deliveries array.
|
||||
config.action_mailer.delivery_method = :test
|
||||
|
||||
|
||||
# Print deprecation notices to the stderr
|
||||
config.active_support.deprecation = :stderr
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
||||
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
||||
|
||||
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
||||
# Rails.backtrace_cleaner.remove_silencers!
|
|
@ -1,15 +0,0 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new inflection rules using the following format
|
||||
# (all these examples are active by default):
|
||||
# ActiveSupport::Inflector.inflections do |inflect|
|
||||
# inflect.plural /^(ox)$/i, '\1en'
|
||||
# inflect.singular /^(ox)en/i, '\1'
|
||||
# inflect.irregular 'person', 'people'
|
||||
# inflect.uncountable %w( fish sheep )
|
||||
# end
|
||||
#
|
||||
# These inflection rules are supported but not enabled by default:
|
||||
# ActiveSupport::Inflector.inflections do |inflect|
|
||||
# inflect.acronym 'RESTful'
|
||||
# end
|
|
@ -1,5 +0,0 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new mime types for use in respond_to blocks:
|
||||
# Mime::Type.register "text/richtext", :rtf
|
||||
# Mime::Type.register_alias "text/html", :iphone
|
|
@ -1,7 +0,0 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Your secret key for verifying the integrity of signed cookies.
|
||||
# If you change this key, all old signed cookies will become invalid!
|
||||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
TestApp::Application.config.secret_token = 'd138d5b7eaa9952739afcb966de453b27d22cced897240fc81a764c51fa66ff212dac9af617c78f7bc734aaf37f4451f7ca1d6e695a3d812babb8c3cbee6875f'
|
|
@ -1,8 +0,0 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
TestApp::Application.config.session_store :cookie_store, key: '_test_app_session'
|
||||
|
||||
# Use the database for sessions instead of the cookie-based default,
|
||||
# which shouldn't be used to store highly confidential information
|
||||
# (create the session table with "rails generate session_migration")
|
||||
# TestApp::Application.config.session_store :active_record_store
|
|
@ -1,10 +0,0 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
#
|
||||
# This file contains settings for ActionController::ParamsWrapper which
|
||||
# is enabled by default.
|
||||
|
||||
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
wrap_parameters format: [:json]
|
||||
end
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# Sample localization file for English. Add more files in this directory for other locales.
|
||||
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||
|
||||
en:
|
||||
hello: "Hello world"
|
|
@ -1,33 +0,0 @@
|
|||
TestApp::Application.routes.draw do
|
||||
|
||||
resource :foo, :controller => 'Foo' do
|
||||
collection do
|
||||
get :basic_action
|
||||
get :callback_from_another_action
|
||||
get :callback_from_another_controller
|
||||
get :callback_from_namespaced_controller
|
||||
get :skip_callback
|
||||
end
|
||||
end
|
||||
|
||||
resource :bar, :controller => 'bar' do
|
||||
collection do
|
||||
get :basic_action
|
||||
get :different_params
|
||||
get :another_basic_action
|
||||
get :yet_another_basic_action
|
||||
end
|
||||
end
|
||||
|
||||
namespace :sample_namespace do
|
||||
resource :baz, :controller => 'baz' do
|
||||
collection do
|
||||
get :basic_action
|
||||
get :another_basic_action
|
||||
get :yet_another_basic_action
|
||||
get :callback_from_another_action
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The page you were looking for doesn't exist (404)</title>
|
||||
<style type="text/css">
|
||||
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
padding: 0 4em;
|
||||
margin: 4em auto 0 auto;
|
||||
border: 1px solid #ccc;
|
||||
border-right-color: #999;
|
||||
border-bottom-color: #999;
|
||||
}
|
||||
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- This file lives in public/404.html -->
|
||||
<div class="dialog">
|
||||
<h1>The page you were looking for doesn't exist.</h1>
|
||||
<p>You may have mistyped the address or the page may have moved.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,26 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The change you wanted was rejected (422)</title>
|
||||
<style type="text/css">
|
||||
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
padding: 0 4em;
|
||||
margin: 4em auto 0 auto;
|
||||
border: 1px solid #ccc;
|
||||
border-right-color: #999;
|
||||
border-bottom-color: #999;
|
||||
}
|
||||
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- This file lives in public/422.html -->
|
||||
<div class="dialog">
|
||||
<h1>The change you wanted was rejected.</h1>
|
||||
<p>Maybe you tried to change something you didn't have access to.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,25 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>We're sorry, but something went wrong (500)</title>
|
||||
<style type="text/css">
|
||||
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
padding: 0 4em;
|
||||
margin: 4em auto 0 auto;
|
||||
border: 1px solid #ccc;
|
||||
border-right-color: #999;
|
||||
border-bottom-color: #999;
|
||||
}
|
||||
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- This file lives in public/500.html -->
|
||||
<div class="dialog">
|
||||
<h1>We're sorry, but something went wrong.</h1>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +0,0 @@
|
|||
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
|
||||
#
|
||||
# To ban all spiders from the entire site uncomment the next two lines:
|
||||
# User-Agent: *
|
||||
# Disallow: /
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
||||
|
||||
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'rails/commands'
|
|
@ -1,87 +0,0 @@
|
|||
require 'rails/generators/named_base'
|
||||
require 'rails/generators/rails/controller/controller_generator'
|
||||
require 'fileutils'
|
||||
require 'generator_spec/test_case'
|
||||
|
||||
|
||||
TEMP = "#{File.dirname(__FILE__)}/tmp/"
|
||||
|
||||
# We override the original Paloma.destination
|
||||
# so that when run_generator command is executed by the specs
|
||||
# Paloma.destination will point to /spec/tmp instead of /test_app itself.
|
||||
$test_destination = "#{TEMP}#{Paloma.destination}"
|
||||
module Paloma
|
||||
def self.destination
|
||||
$test_destination
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def mimic_setup
|
||||
# Mimic SetupGenerator results before running the AddGenerator
|
||||
FileUtils.cd TEMP
|
||||
FileUtils.mkpath Paloma.destination
|
||||
File.open("#{Paloma.destination}/index.js", 'w') {
|
||||
|f| f.write('//= require ./paloma_core.js')
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
def init
|
||||
include GeneratorSpec::TestCase
|
||||
destination TEMP
|
||||
end
|
||||
|
||||
|
||||
|
||||
module GeneratorSpec::Matcher
|
||||
class Directory
|
||||
|
||||
def manifest_js
|
||||
file '_manifest.js'
|
||||
end
|
||||
|
||||
|
||||
def filters_js scope
|
||||
file '_filters.js' do
|
||||
contains "var filter = new Paloma.FilterScope('#{scope}');"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def locals_js scope, options = {:parent => nil, :is_controller => false}
|
||||
file '_locals.js' do
|
||||
contains "var locals = Paloma.locals['#{scope}'] = {};"
|
||||
|
||||
if options[:parent].present?
|
||||
contains "Paloma.inheritLocals({from : '#{options[:parent]}', to : '#{scope}'});"
|
||||
end
|
||||
|
||||
if options[:is_controller]
|
||||
contains "Paloma.callbacks['#{scope}'] = {};"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def action_js controller, action
|
||||
file "#{action}.js" do
|
||||
contains "Paloma.callbacks['#{controller}']['#{action}']"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def controller_structure controller, options = {:parent => '/'}
|
||||
manifest_js
|
||||
filters_js controller
|
||||
locals_js controller, :parent => options[:parent], :is_controller => true
|
||||
end
|
||||
|
||||
|
||||
def namespace_structure namespace
|
||||
manifest_js
|
||||
locals_js namespace, :parent => '/'
|
||||
filters_js namespace
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,199 +0,0 @@
|
|||
require 'spec_helper'
|
||||
require 'generator_helper'
|
||||
|
||||
|
||||
# rails g paloma:setup
|
||||
describe Paloma::SetupGenerator do
|
||||
init
|
||||
|
||||
before do
|
||||
prepare_destination
|
||||
run_generator
|
||||
end
|
||||
|
||||
specify do
|
||||
destination_root.should have_structure {
|
||||
directory Paloma.destination do
|
||||
file 'index.js'
|
||||
filters_js '/'
|
||||
locals_js '/'
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# rails g paloma:add sexy_controller
|
||||
feature Paloma::AddGenerator, 'creating controller folder' do
|
||||
init
|
||||
arguments ['sexy_controller']
|
||||
|
||||
before do
|
||||
prepare_destination
|
||||
mimic_setup
|
||||
run_generator
|
||||
end
|
||||
|
||||
specify do
|
||||
destination_root.should have_structure {
|
||||
directory Paloma.destination do
|
||||
directory 'sexy_controller' do
|
||||
controller_structure 'sexy_controller'
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# rails g paloma:add namespace/new_controller
|
||||
feature Paloma::AddGenerator, 'creating a namespaced controller folder' do
|
||||
init
|
||||
arguments ['namespace/new_controller']
|
||||
|
||||
before do
|
||||
prepare_destination
|
||||
mimic_setup
|
||||
run_generator
|
||||
end
|
||||
|
||||
specify do
|
||||
destination_root.should have_structure {
|
||||
directory Paloma.destination do
|
||||
directory 'namespace' do
|
||||
directory 'new_controller' do
|
||||
controller_structure 'namespace/new_controller', :parent => 'namespace'
|
||||
end
|
||||
|
||||
namespace_structure 'namespace'
|
||||
end
|
||||
|
||||
file 'index.js' do
|
||||
contains "//= require ./namespace/_manifest.js"
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# rails g paloma:add new_controller action1 action2
|
||||
feature Paloma::AddGenerator, 'creating both controller folder and action files' do
|
||||
init
|
||||
arguments ['new_controller', 'action1', 'action2']
|
||||
|
||||
before do
|
||||
prepare_destination
|
||||
mimic_setup
|
||||
run_generator
|
||||
end
|
||||
|
||||
specify do
|
||||
destination_root.should have_structure {
|
||||
directory Paloma.destination do
|
||||
directory 'new_controller' do
|
||||
action_js 'new_controller', 'action1'
|
||||
action_js 'new_controller', 'action2'
|
||||
controller_structure 'new_controller'
|
||||
end
|
||||
|
||||
file 'index.js' do
|
||||
contains "//= require ./new_controller/_manifest.js"
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# rails g paloma:add existing_controller action1 action2
|
||||
feature Paloma::AddGenerator, 'creating actions with existing controller folder' do
|
||||
init
|
||||
arguments ['existing_controller', 'action1', 'action2']
|
||||
|
||||
before do
|
||||
prepare_destination
|
||||
mimic_setup
|
||||
Dir.mkdir "#{Paloma.destination}/existing_controller"
|
||||
|
||||
run_generator
|
||||
end
|
||||
|
||||
specify do
|
||||
destination_root.should have_structure {
|
||||
directory Paloma.destination do
|
||||
directory 'existing_controller' do
|
||||
action_js 'existing_controller', 'action1'
|
||||
action_js 'existing_controller', 'action2'
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# rails g paloma:add namespace/new_controller action1 action2
|
||||
feature Paloma::AddGenerator, 'creating namespaced controller folder and action files' do
|
||||
include GeneratorSpec::TestCase
|
||||
destination TEMP
|
||||
arguments ['namespace/new_controller', 'action1', 'action2']
|
||||
|
||||
before do
|
||||
prepare_destination
|
||||
mimic_setup
|
||||
run_generator
|
||||
end
|
||||
|
||||
specify do
|
||||
destination_root.should have_structure {
|
||||
directory Paloma.destination do
|
||||
directory 'namespace' do
|
||||
directory 'new_controller' do
|
||||
action_js 'namespace/new_controller', 'action1'
|
||||
action_js 'namespace/new_controller', 'action2'
|
||||
controller_structure 'namespace/new_controller', :parent => 'namespace'
|
||||
end
|
||||
|
||||
namespace_structure 'namespace'
|
||||
end
|
||||
|
||||
file 'index.js' do
|
||||
contains "//= require ./namespace/_manifest.js"
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# rails g paloma:add existing_namespace/new_controller_folder new_action
|
||||
feature Paloma::AddGenerator, 'creating controller folder and action file under an existing namespace' do
|
||||
init
|
||||
arguments ['existing_namespace/new_controller', 'action1', 'action2']
|
||||
|
||||
before do
|
||||
prepare_destination
|
||||
mimic_setup
|
||||
Dir.mkdir "#{Paloma.destination}/existing_namespace"
|
||||
|
||||
run_generator
|
||||
end
|
||||
|
||||
specify do
|
||||
destination_root.should have_structure {
|
||||
directory Paloma.destination do
|
||||
directory 'existing_namespace' do
|
||||
directory 'new_controller' do
|
||||
action_js 'existing_namespace/new_controller', 'action1'
|
||||
action_js 'existing_namespace/new_controller', 'action2'
|
||||
controller_structure 'existing_namespace/new_controller',
|
||||
:parent => 'existing_namespace'
|
||||
end
|
||||
|
||||
file '_manifest.js' do
|
||||
contains "//= require ./new_controller/_manifest.js"
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
|
@ -1,54 +0,0 @@
|
|||
require 'spec_helper'
|
||||
require 'generator_helper'
|
||||
|
||||
|
||||
feature ::Rails::Generators::ControllerGenerator, 'generating a rails controller without action' do
|
||||
init
|
||||
arguments ['my_controller']
|
||||
|
||||
before do
|
||||
prepare_destination
|
||||
mimic_setup
|
||||
run_generator
|
||||
end
|
||||
|
||||
specify do
|
||||
destination_root.should have_structure {
|
||||
directory Paloma.destination do
|
||||
directory 'my_controller' do
|
||||
controller_structure 'my_controller'
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
feature ::Rails::Generators::ControllerGenerator, 'generating a rails controller with actions' do
|
||||
init
|
||||
arguments ['my_controller', 'new', 'edit']
|
||||
|
||||
before do
|
||||
prepare_destination
|
||||
|
||||
# Create config/routes.rb
|
||||
FileUtils.cd TEMP
|
||||
FileUtils.mkpath 'config'
|
||||
File.open("config/routes.rb", 'w') { |f| f.write('')}
|
||||
|
||||
mimic_setup
|
||||
run_generator
|
||||
end
|
||||
|
||||
specify do
|
||||
destination_root.should have_structure {
|
||||
directory Paloma.destination do
|
||||
directory 'my_controller' do
|
||||
controller_structure 'my_controller'
|
||||
action_js 'my_controller', 'new'
|
||||
action_js 'my_controller', 'edit'
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
|
@ -1,64 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
|
||||
describe 'Paloma callback', :type => :feature, :js => true do
|
||||
|
||||
context 'when js(false)' do
|
||||
it 'is not executed' do
|
||||
visit skip_callback_foo_path
|
||||
page.evaluate_script('window["callback"] === undefined').should be_true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'when js(:controller => "controller", :action => "action")' do
|
||||
it 'is ["controller"]["action"]' do
|
||||
visit callback_from_another_controller_foo_path
|
||||
page.evaluate_script('callback').should eq "['bar']['basic_action']"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'when js(:controller => "namespace/controller", :action => "action"' do
|
||||
it 'is ["namespace/controller"]["action"]' do
|
||||
visit callback_from_namespaced_controller_foo_path
|
||||
page.evaluate_script('callback').should eq "['sample_namespace/baz']['basic_action']"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'within a non-namespaced controller' do
|
||||
context 'when js() is not directly invoked' do
|
||||
it 'is ["request_controller"]["request_action"]' do
|
||||
visit basic_action_foo_path
|
||||
page.evaluate_script('callback').should eq "['foo']['basic_action']"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'when js(:action)' do
|
||||
it 'is ["request_controller"][:action]' do
|
||||
visit callback_from_another_action_foo_path
|
||||
page.evaluate_script('callback').should eq "['foo']['basic_action']"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'within a namespaced controller' do
|
||||
context 'when js() is not directly invoked' do
|
||||
it 'is ["request_namespace/request_controller"]["request_action"]' do
|
||||
visit basic_action_sample_namespace_baz_path
|
||||
page.evaluate_script('callback').should eq "['sample_namespace/baz']['basic_action']"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'when js(:action)' do
|
||||
it 'is ["request_namespace/request_controller"][:action]' do
|
||||
visit callback_from_another_action_sample_namespace_baz_path
|
||||
page.evaluate_script('callback').should eq "['sample_namespace/baz']['basic_action']"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,187 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Paloma.FilterScope', :type => :feature, :js => true do
|
||||
|
||||
shared_context 'paths-' do
|
||||
let(:basic_action) { basic_action_bar_path }
|
||||
let(:another_basic_action) { another_basic_action_bar_path }
|
||||
let(:yet_another_basic_action) { yet_another_basic_action_bar_path}
|
||||
end
|
||||
|
||||
shared_context 'paths-Application' do
|
||||
include_context 'paths-'
|
||||
end
|
||||
|
||||
shared_context 'paths-Namespaced' do
|
||||
let(:basic_action) { basic_action_sample_namespace_baz_path }
|
||||
let(:another_basic_action) { another_basic_action_sample_namespace_baz_path }
|
||||
let(:yet_another_basic_action) { yet_another_basic_action_sample_namespace_baz_path }
|
||||
end
|
||||
|
||||
|
||||
|
||||
shared_examples 'standard' do |options|
|
||||
type = options[:type]
|
||||
name = options[:name]
|
||||
method = options[:method] || "##{type}"
|
||||
scope = parse_scope options[:scope]
|
||||
filter = "#{scope}Standard #{name}"
|
||||
|
||||
describe method do
|
||||
it "executes filter #{type} callbacks for the passed actions" do
|
||||
visit basic_action
|
||||
page.evaluate_script("filtersExecuted.#{type}").should include filter
|
||||
end
|
||||
|
||||
it "does not execute filter #{type} callbacks for other actions" do
|
||||
visit yet_another_basic_action
|
||||
page.evaluate_script("filtersExecuted.#{type}").should_not include filter
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
shared_examples 'all' do |options|
|
||||
type = options[:type]
|
||||
name = options[:name]
|
||||
method = options[:method] || "##{type}_all"
|
||||
scope = parse_scope options[:scope]
|
||||
filter = "#{scope}#{name} All"
|
||||
|
||||
describe method do
|
||||
it "executes filter #{type} callbacks on all actions" do
|
||||
visit basic_action
|
||||
page.evaluate_script("filtersExecuted.#{type}").should include filter
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
shared_examples 'except' do |options|
|
||||
type = options[:type]
|
||||
name = options[:name]
|
||||
method = options[:method] || "#except_#{type}"
|
||||
scope = parse_scope options[:scope]
|
||||
filter = "#{scope}Except #{name}"
|
||||
|
||||
describe method do
|
||||
it "executes filter #{type} callback on all actions except for passed actions" do
|
||||
visit another_basic_action
|
||||
page.evaluate_script("filtersExecuted.#{type}").should include filter
|
||||
end
|
||||
|
||||
it "does not execute filter #{type} callback on passed actions" do
|
||||
visit basic_action
|
||||
page.evaluate_script("filtersExecuted.#{type}").should_not include filter
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
shared_examples 'filter subtypes' do |options|
|
||||
params = {:type => options[:type],
|
||||
:name => options[:type].titleize,
|
||||
:scope => options[:scope]}
|
||||
|
||||
include_examples 'standard', params
|
||||
include_examples 'all', params
|
||||
include_examples 'except', params
|
||||
end
|
||||
|
||||
|
||||
shared_examples 'filters' do |scope|
|
||||
context "when inside the scope of #{scope}" do
|
||||
include_context "paths-#{scope}"
|
||||
|
||||
def self.parse_scope scope
|
||||
scope.blank? ? scope : "#{scope} "
|
||||
end
|
||||
|
||||
# Before and After Filters
|
||||
include_examples 'filter subtypes', {:type => 'before', :scope => scope}
|
||||
include_examples 'filter subtypes', {:type => 'after', :scope => scope}
|
||||
|
||||
# Around Filters
|
||||
include_examples 'standard', {:name => 'Around',
|
||||
:type => 'before',
|
||||
:method => '#around',
|
||||
:scope => scope}
|
||||
|
||||
include_examples 'standard', {:name => 'Around',
|
||||
:type => 'after',
|
||||
:method => '#around',
|
||||
:scope => scope}
|
||||
|
||||
include_examples 'all', {:name => 'Around',
|
||||
:type => 'before',
|
||||
:method => '#around_all',
|
||||
:scope => scope}
|
||||
|
||||
include_examples 'all', {:name => 'Around',
|
||||
:type => 'after',
|
||||
:method => '#around_all',
|
||||
:scope => scope}
|
||||
|
||||
include_examples 'except', {:name => 'Around',
|
||||
:type => 'before',
|
||||
:method => '#except_around',
|
||||
:scope => scope}
|
||||
|
||||
include_examples 'except', {:name => 'Around',
|
||||
:type => 'after',
|
||||
:method => '#except_around',
|
||||
:scope => scope}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
shared_examples 'skip filters' do |type|
|
||||
name = type.titleize
|
||||
filter = "- Skip This #{name} Filter"
|
||||
|
||||
describe "#skip_#{type}_filter" do
|
||||
context 'when not appended with #only or #expect' do
|
||||
it "skips passed #{type} filters for all actions" do
|
||||
visit basic_action_sample_namespace_baz_path
|
||||
page.evaluate_script("filtersExecuted.#{type}").should_not include "All #{filter}"
|
||||
end
|
||||
end
|
||||
|
||||
context 'with #only' do
|
||||
it "skips passed #{type} filters for actions passed on #only" do
|
||||
visit another_basic_action_sample_namespace_baz_path
|
||||
page.evaluate_script("filtersExecuted.#{type}").should_not include "Only #{filter}"
|
||||
end
|
||||
|
||||
it "performs passed #{type} filters for actions not passed on #only" do
|
||||
visit basic_action_sample_namespace_baz_path
|
||||
page.evaluate_script("filtersExecuted.#{type}").should include "Only #{filter}"
|
||||
end
|
||||
end
|
||||
|
||||
context 'with #except' do
|
||||
it "skips passed #{type} filters for actions not passed on #except" do
|
||||
visit yet_another_basic_action_sample_namespace_baz_path
|
||||
page.evaluate_script("filtersExecuted.#{type}").should_not include "Except #{filter}"
|
||||
end
|
||||
|
||||
it "performs passed #{type} filters for actions passed on #except" do
|
||||
visit another_basic_action_sample_namespace_baz_path
|
||||
page.evaluate_script("filtersExecuted.#{type}").should include "Except #{filter}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
# Testing starts here
|
||||
include_examples 'filters', '' # non-namespaced filters
|
||||
include_examples 'filters', 'Namespaced' # namespaced filters
|
||||
include_examples 'filters', 'Application' # application-wide filters
|
||||
|
||||
#include_examples 'skip filters', 'before'
|
||||
#include_examples 'skip filters', 'after'
|
||||
#include_examples 'skip filters', 'around'
|
||||
end
|
|
@ -1,27 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
|
||||
describe 'Locals', :type => :feature, :js => true do
|
||||
|
||||
before do
|
||||
visit basic_action_foo_path
|
||||
end
|
||||
|
||||
|
||||
describe '_l' do
|
||||
it 'has access to local methods' do
|
||||
page.evaluate_script('helperMethodValue').should be 100
|
||||
end
|
||||
|
||||
|
||||
it 'has access to local variables' do
|
||||
page.evaluate_script('helperVariableValue').should be 99
|
||||
end
|
||||
|
||||
|
||||
it 'can override locals from its parent scope' do
|
||||
page.evaluate_script('overriden').should eq 'Override!'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,116 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Callback params', :type => :feature, :js => true do
|
||||
|
||||
shared_examples 'check params' do |params|
|
||||
specify "callback_controller must be the callback's controller" do
|
||||
page.evaluate_script('params.callback_controller').should eq params[:callback_controller]
|
||||
end
|
||||
|
||||
specify "callback_action must be the callback's action" do
|
||||
page.evaluate_script('params.callback_action').should eq params[:callback_action]
|
||||
end
|
||||
|
||||
specify "callback_namespace must be callback's namespace" do
|
||||
page.evaluate_script('params.callback_namespace').should eq params[:callback_namespace]
|
||||
end
|
||||
|
||||
specify "callback_controller_path must be callback's namespace and controller" do
|
||||
page.evaluate_script('params.callback_controller_path').should eq params[:callback_controller_path]
|
||||
end
|
||||
|
||||
specify "controller must be request's controller" do
|
||||
page.evaluate_script('params.controller').should eq params[:controller]
|
||||
end
|
||||
|
||||
specify "action must be request's action" do
|
||||
page.evaluate_script('params.action').should eq params[:action]
|
||||
end
|
||||
|
||||
specify "namespace must be request's namespace" do
|
||||
page.evaluate_script('params.namespace').should eq params[:namespace]
|
||||
end
|
||||
|
||||
specify "controller_path must be request's namespace and controller" do
|
||||
page.evaluate_script('params.controller_path').should eq params[:controller_path]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'within a non-namespaced callback' do
|
||||
before do
|
||||
visit callback_from_another_action_foo_path
|
||||
end
|
||||
|
||||
include_examples('check params', {
|
||||
:controller => 'foo',
|
||||
:action => 'callback_from_another_action',
|
||||
:namespace => '',
|
||||
:controller_path => 'foo',
|
||||
:callback_controller => 'foo',
|
||||
:callback_action => 'basic_action',
|
||||
:callback_namespace => '',
|
||||
:callback_controller_path => 'foo'})
|
||||
end
|
||||
|
||||
|
||||
context 'within a namespaced callback' do
|
||||
before do
|
||||
visit callback_from_another_action_sample_namespace_baz_path
|
||||
end
|
||||
|
||||
include_examples('check params', {
|
||||
:controller => 'baz',
|
||||
:action => 'callback_from_another_action',
|
||||
:namespace => 'sample_namespace',
|
||||
:controller_path => 'sample_namespace/baz',
|
||||
:callback_controller => 'baz',
|
||||
:callback_action => 'basic_action',
|
||||
:callback_namespace => 'sample_namespace',
|
||||
:callback_controller_path => 'sample_namespace/baz'})
|
||||
end
|
||||
|
||||
|
||||
context 'with passed parameter' do
|
||||
before do
|
||||
visit different_params_bar_path
|
||||
end
|
||||
|
||||
context 'of type TrueClass or FalseClass' do
|
||||
it 'has the boolean equivalent' do
|
||||
page.evaluate_script("params['boolean'] == true").should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context 'of type Array' do
|
||||
it 'has the array equivalent' do
|
||||
page.evaluate_script("JSON.stringify(params['array']) == JSON.stringify([1, 2, 3])").should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context 'of type String' do
|
||||
it 'has the string equivalent' do
|
||||
page.evaluate_script("params['string'] == 'Banana'").should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context 'of type Fixnum' do
|
||||
it 'has the number equivalent' do
|
||||
page.evaluate_script("params['integer'] == 69").should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context 'of type Float' do
|
||||
it 'has the number equivalent' do
|
||||
page.evaluate_script("params['float'] == 3.1416").should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context 'of type Hash' do
|
||||
it 'has the object equivalent' do
|
||||
page.evaluate_script(
|
||||
"JSON.stringify(params['hash']) == JSON.stringify({a : 'Hello', b : 'World'})").should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,58 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
|
||||
describe 'Skip Filter', :type => :feature, :js => true do
|
||||
|
||||
def filters_executed type
|
||||
page.evaluate_script("filtersExecuted.#{type}")
|
||||
end
|
||||
|
||||
|
||||
shared_examples 'skip_*_filter/s' do |execution, name|
|
||||
|
||||
describe "#skip_#{name}_filter/s" do
|
||||
context "with no inclusion method called" do
|
||||
it "skips the #{name} filters" do
|
||||
visit basic_action_bar_path
|
||||
filters_executed(execution).should_not include "Standard Skip #{name.titleize} Filter"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "with #only inclusion method called" do
|
||||
filter = "Only Skip #{name.titleize} Filter"
|
||||
|
||||
it "skips the #{name} filters for the actions passed" do
|
||||
visit basic_action_bar_path
|
||||
filters_executed(execution).should_not include filter
|
||||
end
|
||||
|
||||
it "does not skip the #{name} filters for the other actions" do
|
||||
visit another_basic_action_bar_path
|
||||
filters_executed(execution).should include filter
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "with #except inclusion method called" do
|
||||
filter = "Except Skip #{name.titleize} Filter"
|
||||
|
||||
it "skips the #{name} filters for the actions which are not passed" do
|
||||
visit basic_action_bar_path
|
||||
filters_executed(execution).should_not include filter
|
||||
end
|
||||
|
||||
it "does not skip the #{name} filters for the actions passed" do
|
||||
visit yet_another_basic_action_bar_path
|
||||
filters_executed(execution).should include filter
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
include_examples 'skip_*_filter/s', 'before', 'before'
|
||||
include_examples 'skip_*_filter/s', 'after', 'after'
|
||||
include_examples 'skip_*_filter/s', 'before', 'around'
|
||||
include_examples 'skip_*_filter/s', 'after', 'around'
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
|
||||
describe '_x', :type => :feature, :js => true do
|
||||
|
||||
before do
|
||||
visit basic_action_foo_path
|
||||
end
|
||||
|
||||
|
||||
it 'is visible on filters and callback' do
|
||||
final_x = page.evaluate_script 'window.xVisibilityFinal'
|
||||
final_x.should eq ['Before Foo', 'Around Foo', 'Foo', 'After Foo', 'Around Foo']
|
||||
end
|
||||
|
||||
|
||||
it 'is empty after filter and callback executions' do
|
||||
x = page.evaluate_script 'Paloma.variableContainer'
|
||||
x.should be_empty
|
||||
end
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require 'rspec/rails'
|
||||
require 'rspec/autorun'
|
||||
require 'capybara/rspec'
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
||||
|
||||
RSpec.configure do |config|
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
# automatically. This will be the default behavior in future versions of
|
||||
# rspec-rails.
|
||||
config.infer_base_class_for_anonymous_controllers = false
|
||||
|
||||
# Run specs in random order to surface order dependencies. If you find an
|
||||
# order dependency and want to debug it, you can fix the order by providing
|
||||
# the seed, which is printed after each run.
|
||||
# --seed 1234
|
||||
config.order = "random"
|
||||
end
|
||||
|
||||
|
||||
|
6
test.js
6
test.js
|
@ -38,4 +38,8 @@ controller.prototype.edit = function(){
|
|||
|
||||
|
||||
|
||||
var adminAuthorController = Paloma.Controller.register('Admin.Authors');
|
||||
var adminAuthorController = Paloma.Controller.register('Admin.Authors');
|
||||
|
||||
|
||||
|
||||
js :x => 1, :y => 2
|
|
@ -15,6 +15,8 @@
|
|||
//= require paloma
|
||||
//= require_tree .
|
||||
|
||||
Paloma.config.ignoreMissingController = false;
|
||||
|
||||
var router = Paloma.router;
|
||||
|
||||
router.resource('RailsUser', {controller: 'User'});
|
||||
|
@ -33,6 +35,12 @@ User.prototype.update = function(){
|
|||
};
|
||||
|
||||
|
||||
Paloma.controller('Main').prototype.index = function(){
|
||||
//console.log('main');
|
||||
alert('main');
|
||||
};
|
||||
|
||||
/*
|
||||
Paloma.engine.requests.push({resource: 'RailsUser', action: 'revise', params: {id: 23}});
|
||||
Paloma.engine.requests.push({resource: 'RailsUser', action: 'revise', params: {id: 99}});
|
||||
|
||||
|
@ -40,4 +48,7 @@ Paloma.engine.requests.push({resource: 'User', action: 'update', params: {name:
|
|||
|
||||
Paloma.engine.requests.push({resource: 'Article', action: 'new'});
|
||||
|
||||
Paloma.engine.start();
|
||||
|
||||
Paloma.engine.start();
|
||||
|
||||
*/
|
8
vendor/assets/javascripts/paloma/paloma.js
vendored
8
vendor/assets/javascripts/paloma/paloma.js
vendored
|
@ -1,5 +1,11 @@
|
|||
(function(Paloma){
|
||||
|
||||
Paloma.config = {};
|
||||
|
||||
// Defaults
|
||||
Paloma.config.ignoreMissingController = true;
|
||||
|
||||
|
||||
Paloma.router = new Paloma.Router({namespace: '/', action: '#'});
|
||||
|
||||
|
||||
|
@ -51,7 +57,7 @@
|
|||
console.log('mapping <' + request.resource + '> to controller <' + controllerName + '>');
|
||||
console.log('mapping action <' + request.action + '> to controller action <' + action + '>');
|
||||
|
||||
var Controller = Paloma.controller(controllerName);
|
||||
var Controller = Paloma._controllerFactory.get(controllerName);
|
||||
|
||||
if (!Controller){
|
||||
return console.error('Paloma: undefined controller -> ' + controllerName);
|
||||
|
|
Loading…
Reference in a new issue