mirror of
https://github.com/kbparagua/paloma
synced 2023-03-27 23:21:17 -04:00
Completed params spec
This commit is contained in:
parent
6817c4b292
commit
1951c09645
4 changed files with 80 additions and 1 deletions
|
@ -0,0 +1,4 @@
|
|||
Paloma.callbacks['bar']['different_params'] = function(params)
|
||||
{
|
||||
window.params = params;
|
||||
};
|
|
@ -2,4 +2,17 @@ class BarController < ApplicationController
|
|||
def basic_action
|
||||
render :inline => '<h1>Bar! 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
|
||||
|
|
|
@ -13,6 +13,7 @@ TestApp::Application.routes.draw do
|
|||
resource :bar, :controller => 'bar' do
|
||||
collection do
|
||||
get :basic_action
|
||||
get :different_params
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -51,5 +51,66 @@ describe 'Callback params', :type => :feature, :js => true do
|
|||
:callback_action => 'basic_action',
|
||||
:callback_namespace => '',
|
||||
:callback_controller_path => 'foo'})
|
||||
end
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue