paloma 1.2.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -3
- data/Changelog.md +0 -4
- data/README.md +206 -67
- data/app/templates/_filters.js +14 -0
- data/app/templates/application/_locals.js +13 -0
- data/app/templates/controller/_locals.js +19 -0
- data/app/templates/controller/_manifest.js +3 -0
- data/app/templates/controller/action.js +23 -0
- data/app/templates/index.js +3 -1
- data/app/templates/namespace/_locals.js +16 -0
- data/app/templates/namespace/_manifest.js +3 -0
- data/app/views/paloma/_callback_hook.html.erb +31 -26
- data/lib/paloma.rb +3 -0
- data/lib/paloma/action_controller_extension.rb +18 -16
- data/lib/paloma/action_controller_filters.rb +4 -7
- data/lib/paloma/generators/add_generator.rb +81 -85
- data/lib/paloma/generators/setup_generator.rb +15 -5
- data/lib/paloma/rails/controller_generator.rb +11 -0
- data/lib/paloma/rails/engine.rb +6 -0
- data/paloma.gemspec +1 -3
- data/spec/test_app/.gitignore +15 -0
- data/spec/test_app/.rspec +1 -0
- data/spec/test_app/Gemfile +2 -0
- data/spec/test_app/README.rdoc +261 -0
- data/spec/test_app/Rakefile +16 -0
- data/spec/test_app/app/assets/javascripts/application.js +16 -0
- data/spec/test_app/app/assets/javascripts/paloma/_filters.js +130 -0
- data/spec/test_app/app/assets/javascripts/paloma/_locals.js +17 -0
- data/spec/test_app/app/assets/javascripts/paloma/bar/_filters.js +96 -0
- data/spec/test_app/app/assets/javascripts/paloma/bar/_locals.js +1 -0
- data/spec/test_app/app/assets/javascripts/paloma/bar/_manifest.js +3 -0
- data/spec/test_app/app/assets/javascripts/paloma/bar/another_basic_action.js +5 -0
- data/spec/test_app/app/assets/javascripts/paloma/bar/basic_action.js +5 -0
- data/spec/test_app/app/assets/javascripts/paloma/bar/different_params.js +4 -0
- data/spec/test_app/app/assets/javascripts/paloma/bar/yet_another_basic_action.js +5 -0
- data/spec/test_app/app/assets/javascripts/paloma/foo/_filters.js +24 -0
- data/spec/test_app/app/assets/javascripts/paloma/foo/_locals.js +21 -0
- data/spec/test_app/app/assets/javascripts/paloma/foo/_manifest.js +3 -0
- data/spec/test_app/app/assets/javascripts/paloma/foo/basic_action.js +21 -0
- data/spec/test_app/app/assets/javascripts/paloma/foo/skip_callback.js +6 -0
- data/spec/test_app/app/assets/javascripts/paloma/index.js +6 -0
- data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/_filters.js +83 -0
- data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/_manifest.js +2 -0
- data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/_filters.js +84 -0
- data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/_locals.js +1 -0
- data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/_manifest.js +2 -0
- data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/another_basic_action.js +5 -0
- data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/basic_action.js +5 -0
- data/spec/test_app/app/assets/javascripts/paloma/sample_namespace/baz/yet_another_basic_action.js +5 -0
- data/spec/test_app/app/controllers/application_controller.rb +3 -0
- data/spec/test_app/app/controllers/bar_controller.rb +28 -0
- data/spec/test_app/app/controllers/foo_controller.rb +25 -0
- data/spec/test_app/app/controllers/sample_namespace/baz_controller.rb +23 -0
- data/spec/{sample_app → test_app}/app/views/layouts/application.html.erb +0 -0
- data/spec/test_app/config.ru +4 -0
- data/spec/test_app/config/application.rb +74 -0
- data/spec/test_app/config/boot.rb +6 -0
- data/spec/test_app/config/environment.rb +5 -0
- data/spec/test_app/config/environments/development.rb +31 -0
- data/spec/test_app/config/environments/production.rb +64 -0
- data/spec/test_app/config/environments/test.rb +35 -0
- data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/test_app/config/initializers/inflections.rb +15 -0
- data/spec/test_app/config/initializers/mime_types.rb +5 -0
- data/spec/test_app/config/initializers/secret_token.rb +7 -0
- data/spec/test_app/config/initializers/session_store.rb +8 -0
- data/spec/test_app/config/initializers/wrap_parameters.rb +10 -0
- data/spec/test_app/config/locales/en.yml +5 -0
- data/spec/test_app/config/routes.rb +33 -0
- data/spec/test_app/log/.gitkeep +0 -0
- data/spec/test_app/public/404.html +26 -0
- data/spec/test_app/public/422.html +26 -0
- data/spec/test_app/public/500.html +25 -0
- data/spec/test_app/public/favicon.ico +0 -0
- data/spec/test_app/public/robots.txt +5 -0
- data/spec/test_app/script/rails +6 -0
- data/spec/test_app/spec/generator_helper.rb +87 -0
- data/spec/test_app/spec/generators/paloma_generator_spec.rb +199 -0
- data/spec/test_app/spec/generators/rails_generator_spec.rb +54 -0
- data/spec/test_app/spec/javascripts/callback_spec.rb +64 -0
- data/spec/test_app/spec/javascripts/filters_spec.rb +187 -0
- data/spec/test_app/spec/javascripts/locals_spec.rb +27 -0
- data/spec/test_app/spec/javascripts/params_spec.rb +116 -0
- data/spec/test_app/spec/javascripts/skip_filters_spec.rb +58 -0
- data/spec/test_app/spec/javascripts/variable_container_spec.rb +21 -0
- data/spec/test_app/spec/spec_helper.rb +26 -0
- data/vendor/assets/javascripts/paloma_core.js +294 -0
- metadata +79 -68
- data/Rakefile +0 -28
- data/app/templates/_callbacks.js +0 -2
- data/app/templates/_local.js +0 -20
- data/app/templates/action.js +0 -5
- data/app/templates/paloma.js +0 -22
- data/spec/callback_spec.rb +0 -81
- data/spec/generator_spec.rb +0 -425
- data/spec/sample_app/app/assets/javascripts/application.js +0 -4
- data/spec/sample_app/app/assets/javascripts/paloma/articles/_callbacks.js +0 -1
- data/spec/sample_app/app/assets/javascripts/paloma/articles/create.js +0 -3
- data/spec/sample_app/app/assets/javascripts/paloma/articles/edit.js +0 -3
- data/spec/sample_app/app/assets/javascripts/paloma/articles/index.js +0 -3
- data/spec/sample_app/app/assets/javascripts/paloma/articles/new.js +0 -3
- data/spec/sample_app/app/assets/javascripts/paloma/articles/show.js +0 -3
- data/spec/sample_app/app/assets/javascripts/paloma/articles/update.js +0 -3
- data/spec/sample_app/app/assets/javascripts/paloma/index.js +0 -3
- data/spec/sample_app/app/assets/javascripts/paloma/paloma.js +0 -1
- data/spec/sample_app/app/assets/javascripts/paloma/sample_namespace/_callbacks.js +0 -1
- data/spec/sample_app/app/assets/javascripts/paloma/sample_namespace/categories/_callbacks.js +0 -1
- data/spec/sample_app/app/assets/javascripts/paloma/sample_namespace/categories/index.js +0 -3
- data/spec/sample_app/app/views/articles/index.html.erb +0 -5
- data/spec/sample_app/app/views/articles/new.html.erb +0 -9
- data/spec/sample_app/app/views/articles/show.html.erb +0 -2
- data/spec/sample_app/app/views/sample_namespace/categories/index.html.erb +0 -5
- data/spec/sample_app/app/views/sample_namespace/categories/new.html.erb +0 -5
- data/spec/sample_app/controllers.rb +0 -68
- data/spec/sample_app/init.rb +0 -37
- data/spec/sample_app/models.rb +0 -40
- data/spec/spec_helper.rb +0 -21
- data/spec/test_app/log/development.log +0 -4
- data/spec/test_app/tmp/cache/assets/CF0/DA0/sprockets%2Fd7d5b37686831d37c4dd75e645f5e016 +0 -0
- data/spec/test_app/tmp/cache/assets/E25/4C0/sprockets%2Fde2fd9fd11c04a582cdbbe3d84a35ae6 +0 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'rails/generators/named_base'
|
2
|
+
require 'rails/generators/rails/controller/controller_generator'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'generator_spec/test_case'
|
5
|
+
|
6
|
+
|
7
|
+
TEMP = "#{File.dirname(__FILE__)}/tmp/"
|
8
|
+
|
9
|
+
# We override the original Paloma.destination
|
10
|
+
# so that when run_generator command is executed by the specs
|
11
|
+
# Paloma.destination will point to /spec/tmp instead of /test_app itself.
|
12
|
+
$test_destination = "#{TEMP}#{Paloma.destination}"
|
13
|
+
module Paloma
|
14
|
+
def self.destination
|
15
|
+
$test_destination
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def mimic_setup
|
21
|
+
# Mimic SetupGenerator results before running the AddGenerator
|
22
|
+
FileUtils.cd TEMP
|
23
|
+
FileUtils.mkpath Paloma.destination
|
24
|
+
File.open("#{Paloma.destination}/index.js", 'w') {
|
25
|
+
|f| f.write('//= require ./paloma_core.js')
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def init
|
31
|
+
include GeneratorSpec::TestCase
|
32
|
+
destination TEMP
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
module GeneratorSpec::Matcher
|
38
|
+
class Directory
|
39
|
+
|
40
|
+
def manifest_js
|
41
|
+
file '_manifest.js'
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def filters_js scope
|
46
|
+
file '_filters.js' do
|
47
|
+
contains "var filter = new Paloma.FilterScope('#{scope}');"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def locals_js scope, options = {:parent => nil, :is_controller => false}
|
53
|
+
file '_locals.js' do
|
54
|
+
contains "var locals = Paloma.locals['#{scope}'] = {};"
|
55
|
+
|
56
|
+
if options[:parent].present?
|
57
|
+
contains "Paloma.inheritLocals({from : '#{options[:parent]}', to : '#{scope}'});"
|
58
|
+
end
|
59
|
+
|
60
|
+
if options[:is_controller]
|
61
|
+
contains "Paloma.callbacks['#{scope}'] = {};"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def action_js controller, action
|
68
|
+
file "#{action}.js" do
|
69
|
+
contains "Paloma.callbacks['#{controller}']['#{action}']"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def controller_structure controller, options = {:parent => '/'}
|
75
|
+
manifest_js
|
76
|
+
filters_js controller
|
77
|
+
locals_js controller, :parent => options[:parent], :is_controller => true
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
def namespace_structure namespace
|
82
|
+
manifest_js
|
83
|
+
locals_js namespace, :parent => '/'
|
84
|
+
filters_js namespace
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'generator_helper'
|
3
|
+
|
4
|
+
|
5
|
+
# rails g paloma:setup
|
6
|
+
describe Paloma::SetupGenerator do
|
7
|
+
init
|
8
|
+
|
9
|
+
before do
|
10
|
+
prepare_destination
|
11
|
+
run_generator
|
12
|
+
end
|
13
|
+
|
14
|
+
specify do
|
15
|
+
destination_root.should have_structure {
|
16
|
+
directory Paloma.destination do
|
17
|
+
file 'index.js'
|
18
|
+
filters_js '/'
|
19
|
+
locals_js '/'
|
20
|
+
end
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# rails g paloma:add sexy_controller
|
27
|
+
feature Paloma::AddGenerator, 'creating controller folder' do
|
28
|
+
init
|
29
|
+
arguments ['sexy_controller']
|
30
|
+
|
31
|
+
before do
|
32
|
+
prepare_destination
|
33
|
+
mimic_setup
|
34
|
+
run_generator
|
35
|
+
end
|
36
|
+
|
37
|
+
specify do
|
38
|
+
destination_root.should have_structure {
|
39
|
+
directory Paloma.destination do
|
40
|
+
directory 'sexy_controller' do
|
41
|
+
controller_structure 'sexy_controller'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# rails g paloma:add namespace/new_controller
|
49
|
+
feature Paloma::AddGenerator, 'creating a namespaced controller folder' do
|
50
|
+
init
|
51
|
+
arguments ['namespace/new_controller']
|
52
|
+
|
53
|
+
before do
|
54
|
+
prepare_destination
|
55
|
+
mimic_setup
|
56
|
+
run_generator
|
57
|
+
end
|
58
|
+
|
59
|
+
specify do
|
60
|
+
destination_root.should have_structure {
|
61
|
+
directory Paloma.destination do
|
62
|
+
directory 'namespace' do
|
63
|
+
directory 'new_controller' do
|
64
|
+
controller_structure 'namespace/new_controller', :parent => 'namespace'
|
65
|
+
end
|
66
|
+
|
67
|
+
namespace_structure 'namespace'
|
68
|
+
end
|
69
|
+
|
70
|
+
file 'index.js' do
|
71
|
+
contains "//= require ./namespace/_manifest.js"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
# rails g paloma:add new_controller action1 action2
|
80
|
+
feature Paloma::AddGenerator, 'creating both controller folder and action files' do
|
81
|
+
init
|
82
|
+
arguments ['new_controller', 'action1', 'action2']
|
83
|
+
|
84
|
+
before do
|
85
|
+
prepare_destination
|
86
|
+
mimic_setup
|
87
|
+
run_generator
|
88
|
+
end
|
89
|
+
|
90
|
+
specify do
|
91
|
+
destination_root.should have_structure {
|
92
|
+
directory Paloma.destination do
|
93
|
+
directory 'new_controller' do
|
94
|
+
action_js 'new_controller', 'action1'
|
95
|
+
action_js 'new_controller', 'action2'
|
96
|
+
controller_structure 'new_controller'
|
97
|
+
end
|
98
|
+
|
99
|
+
file 'index.js' do
|
100
|
+
contains "//= require ./new_controller/_manifest.js"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
}
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
# rails g paloma:add existing_controller action1 action2
|
109
|
+
feature Paloma::AddGenerator, 'creating actions with existing controller folder' do
|
110
|
+
init
|
111
|
+
arguments ['existing_controller', 'action1', 'action2']
|
112
|
+
|
113
|
+
before do
|
114
|
+
prepare_destination
|
115
|
+
mimic_setup
|
116
|
+
Dir.mkdir "#{Paloma.destination}/existing_controller"
|
117
|
+
|
118
|
+
run_generator
|
119
|
+
end
|
120
|
+
|
121
|
+
specify do
|
122
|
+
destination_root.should have_structure {
|
123
|
+
directory Paloma.destination do
|
124
|
+
directory 'existing_controller' do
|
125
|
+
action_js 'existing_controller', 'action1'
|
126
|
+
action_js 'existing_controller', 'action2'
|
127
|
+
end
|
128
|
+
end
|
129
|
+
}
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
# rails g paloma:add namespace/new_controller action1 action2
|
135
|
+
feature Paloma::AddGenerator, 'creating namespaced controller folder and action files' do
|
136
|
+
include GeneratorSpec::TestCase
|
137
|
+
destination TEMP
|
138
|
+
arguments ['namespace/new_controller', 'action1', 'action2']
|
139
|
+
|
140
|
+
before do
|
141
|
+
prepare_destination
|
142
|
+
mimic_setup
|
143
|
+
run_generator
|
144
|
+
end
|
145
|
+
|
146
|
+
specify do
|
147
|
+
destination_root.should have_structure {
|
148
|
+
directory Paloma.destination do
|
149
|
+
directory 'namespace' do
|
150
|
+
directory 'new_controller' do
|
151
|
+
action_js 'namespace/new_controller', 'action1'
|
152
|
+
action_js 'namespace/new_controller', 'action2'
|
153
|
+
controller_structure 'namespace/new_controller', :parent => 'namespace'
|
154
|
+
end
|
155
|
+
|
156
|
+
namespace_structure 'namespace'
|
157
|
+
end
|
158
|
+
|
159
|
+
file 'index.js' do
|
160
|
+
contains "//= require ./namespace/_manifest.js"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
}
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
# rails g paloma:add existing_namespace/new_controller_folder new_action
|
169
|
+
feature Paloma::AddGenerator, 'creating controller folder and action file under an existing namespace' do
|
170
|
+
init
|
171
|
+
arguments ['existing_namespace/new_controller', 'action1', 'action2']
|
172
|
+
|
173
|
+
before do
|
174
|
+
prepare_destination
|
175
|
+
mimic_setup
|
176
|
+
Dir.mkdir "#{Paloma.destination}/existing_namespace"
|
177
|
+
|
178
|
+
run_generator
|
179
|
+
end
|
180
|
+
|
181
|
+
specify do
|
182
|
+
destination_root.should have_structure {
|
183
|
+
directory Paloma.destination do
|
184
|
+
directory 'existing_namespace' do
|
185
|
+
directory 'new_controller' do
|
186
|
+
action_js 'existing_namespace/new_controller', 'action1'
|
187
|
+
action_js 'existing_namespace/new_controller', 'action2'
|
188
|
+
controller_structure 'existing_namespace/new_controller',
|
189
|
+
:parent => 'existing_namespace'
|
190
|
+
end
|
191
|
+
|
192
|
+
file '_manifest.js' do
|
193
|
+
contains "//= require ./new_controller/_manifest.js"
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
}
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'generator_helper'
|
3
|
+
|
4
|
+
|
5
|
+
feature ::Rails::Generators::ControllerGenerator, 'generating a rails controller without action' do
|
6
|
+
init
|
7
|
+
arguments ['my_controller']
|
8
|
+
|
9
|
+
before do
|
10
|
+
prepare_destination
|
11
|
+
mimic_setup
|
12
|
+
run_generator
|
13
|
+
end
|
14
|
+
|
15
|
+
specify do
|
16
|
+
destination_root.should have_structure {
|
17
|
+
directory Paloma.destination do
|
18
|
+
directory 'my_controller' do
|
19
|
+
controller_structure 'my_controller'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
feature ::Rails::Generators::ControllerGenerator, 'generating a rails controller with actions' do
|
28
|
+
init
|
29
|
+
arguments ['my_controller', 'new', 'edit']
|
30
|
+
|
31
|
+
before do
|
32
|
+
prepare_destination
|
33
|
+
|
34
|
+
# Create config/routes.rb
|
35
|
+
FileUtils.cd TEMP
|
36
|
+
FileUtils.mkpath 'config'
|
37
|
+
File.open("config/routes.rb", 'w') { |f| f.write('')}
|
38
|
+
|
39
|
+
mimic_setup
|
40
|
+
run_generator
|
41
|
+
end
|
42
|
+
|
43
|
+
specify do
|
44
|
+
destination_root.should have_structure {
|
45
|
+
directory Paloma.destination do
|
46
|
+
directory 'my_controller' do
|
47
|
+
controller_structure 'my_controller'
|
48
|
+
action_js 'my_controller', 'new'
|
49
|
+
action_js 'my_controller', 'edit'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe 'Paloma callback', :type => :feature, :js => true do
|
5
|
+
|
6
|
+
context 'when js(false)' do
|
7
|
+
it 'is not executed' do
|
8
|
+
visit skip_callback_foo_path
|
9
|
+
page.evaluate_script('window["callback"] === undefined').should be_true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
context 'when js(:controller => "controller", :action => "action")' do
|
15
|
+
it 'is ["controller"]["action"]' do
|
16
|
+
visit callback_from_another_controller_foo_path
|
17
|
+
page.evaluate_script('callback').should eq "['bar']['basic_action']"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
context 'when js(:controller => "namespace/controller", :action => "action"' do
|
23
|
+
it 'is ["namespace/controller"]["action"]' do
|
24
|
+
visit callback_from_namespaced_controller_foo_path
|
25
|
+
page.evaluate_script('callback').should eq "['sample_namespace/baz']['basic_action']"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
context 'within a non-namespaced controller' do
|
31
|
+
context 'when js() is not directly invoked' do
|
32
|
+
it 'is ["request_controller"]["request_action"]' do
|
33
|
+
visit basic_action_foo_path
|
34
|
+
page.evaluate_script('callback').should eq "['foo']['basic_action']"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
context 'when js(:action)' do
|
40
|
+
it 'is ["request_controller"][:action]' do
|
41
|
+
visit callback_from_another_action_foo_path
|
42
|
+
page.evaluate_script('callback').should eq "['foo']['basic_action']"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
context 'within a namespaced controller' do
|
49
|
+
context 'when js() is not directly invoked' do
|
50
|
+
it 'is ["request_namespace/request_controller"]["request_action"]' do
|
51
|
+
visit basic_action_sample_namespace_baz_path
|
52
|
+
page.evaluate_script('callback').should eq "['sample_namespace/baz']['basic_action']"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
context 'when js(:action)' do
|
58
|
+
it 'is ["request_namespace/request_controller"][:action]' do
|
59
|
+
visit callback_from_another_action_sample_namespace_baz_path
|
60
|
+
page.evaluate_script('callback').should eq "['sample_namespace/baz']['basic_action']"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|