activeadmin 1.0.0.pre5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activeadmin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +27 -0
- data/.travis.yml +21 -23
- data/Appraisals +12 -74
- data/CHANGELOG.md +21 -5
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +8 -9
- data/README.md +19 -56
- data/Rakefile +1 -1
- data/activeadmin.gemspec +4 -4
- data/app/assets/stylesheets/active_admin/_forms.scss +10 -0
- data/config/locales/ca.yml +1 -1
- data/config/locales/da.yml +44 -12
- data/config/locales/el.yml +1 -1
- data/config/locales/en.yml +2 -0
- data/config/locales/fr.yml +16 -2
- data/config/locales/ja.yml +1 -0
- data/config/locales/zh-CN.yml +4 -0
- data/docs/12-arbre-components.md +23 -0
- data/docs/14-gotchas.md +1 -1
- data/docs/2-resource-customization.md +2 -5
- data/docs/5-forms.md +19 -0
- data/docs/6-show-pages.md +0 -28
- data/docs/9-batch-actions.md +0 -1
- data/docs/CNAME +1 -1
- data/docs/_includes/head.html +4 -4
- data/docs/_includes/toc.html +2 -1
- data/docs/documentation.md +2 -2
- data/docs/index.html +1 -6
- data/docs/stylesheets/main.css +172 -219
- data/features/belongs_to.feature +5 -5
- data/features/comments/commenting.feature +0 -13
- data/features/create_another.feature +55 -0
- data/features/development_reloading.feature +2 -4
- data/features/edit_page.feature +6 -7
- data/features/favicon.feature +2 -2
- data/features/i18n.feature +1 -0
- data/features/index/filters.feature +18 -0
- data/features/index/format_as_csv.feature +3 -3
- data/features/index/formats.feature +22 -0
- data/features/index/index_as_table.feature +6 -6
- data/features/index/page_title.feature +1 -2
- data/features/menu.feature +20 -1
- data/features/new_page.feature +6 -8
- data/features/registering_assets.feature +4 -4
- data/features/registering_pages.feature +18 -0
- data/features/renamed_resource.feature +2 -4
- data/features/show/page_title.feature +1 -2
- data/features/step_definitions/attribute_steps.rb +1 -1
- data/features/step_definitions/configuration_steps.rb +2 -2
- data/features/step_definitions/format_steps.rb +4 -0
- data/features/step_definitions/index_scope_steps.rb +1 -1
- data/features/step_definitions/menu_steps.rb +2 -2
- data/features/step_definitions/user_steps.rb +1 -1
- data/features/step_definitions/web_steps.rb +6 -5
- data/features/sti_resource.feature +2 -2
- data/features/strong_parameters.feature +0 -4
- data/features/support/env.rb +5 -19
- data/features/support/paths.rb +6 -9
- data/gemfiles/rails_42.gemfile +15 -23
- data/gemfiles/rails_50.gemfile +15 -16
- data/gemfiles/rails_51.gemfile +45 -0
- data/lib/active_admin/application.rb +4 -0
- data/lib/active_admin/base_controller.rb +2 -7
- data/lib/active_admin/base_controller/menu.rb +1 -5
- data/lib/active_admin/csv_builder.rb +2 -2
- data/lib/active_admin/dependency.rb +4 -8
- data/lib/active_admin/devise.rb +1 -1
- data/lib/active_admin/error.rb +1 -1
- data/lib/active_admin/filters/active.rb +2 -10
- data/lib/active_admin/filters/resource_extension.rb +1 -10
- data/lib/active_admin/inputs/filters/date_range_input.rb +1 -1
- data/lib/active_admin/inputs/filters/select_input.rb +1 -2
- data/lib/active_admin/inputs/filters/text_input.rb +2 -2
- data/lib/active_admin/menu.rb +1 -1
- data/lib/active_admin/namespace.rb +14 -7
- data/lib/active_admin/orm/active_record/comments.rb +2 -7
- data/lib/active_admin/orm/active_record/comments/comment.rb +2 -12
- data/lib/active_admin/page.rb +5 -0
- data/lib/active_admin/page_controller.rb +1 -5
- data/lib/active_admin/resource.rb +28 -5
- data/lib/active_admin/resource/attributes.rb +44 -0
- data/lib/active_admin/resource/menu.rb +4 -1
- data/lib/active_admin/resource/routes.rb +2 -3
- data/lib/active_admin/resource_controller.rb +13 -0
- data/lib/active_admin/resource_controller/data_access.rb +18 -9
- data/lib/active_admin/resource_dsl.rb +21 -18
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +1 -1
- data/lib/active_admin/view_helpers/display_helper.rb +10 -12
- data/lib/active_admin/view_helpers/download_format_links_helper.rb +12 -0
- data/lib/active_admin/view_helpers/fields_for.rb +1 -2
- data/lib/active_admin/view_helpers/form_helper.rb +1 -1
- data/lib/active_admin/views/components/active_admin_form.rb +28 -2
- data/lib/active_admin/views/components/paginated_collection.rb +3 -8
- data/lib/active_admin/views/components/table_for.rb +1 -1
- data/lib/active_admin/views/index_as_table.rb +2 -2
- data/lib/active_admin/views/pages/layout.rb +1 -1
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/bug_report_templates/rails_5_master.rb +1 -3
- data/lib/generators/active_admin/devise/devise_generator.rb +1 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +7 -0
- data/lib/generators/active_admin/install/templates/admin_user.rb.erb +0 -2
- data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb.erb +5 -7
- data/lib/generators/active_admin/resource/resource_generator.rb +1 -1
- data/lib/generators/active_admin/resource/templates/{admin.rb → admin.rb.erb} +0 -2
- data/lib/ransack_ext.rb +2 -2
- data/spec/rails_helper.rb +1 -19
- data/spec/requests/default_namespace_spec.rb +40 -8
- data/spec/support/active_admin_integration_spec_helper.rb +9 -2
- data/spec/support/rails_template.rb +17 -20
- data/spec/support/rails_template_with_data.rb +3 -9
- data/spec/support/templates/admin/stores.rb +1 -3
- data/spec/unit/application_spec.rb +19 -8
- data/spec/unit/belongs_to_spec.rb +6 -2
- data/spec/unit/comments_spec.rb +0 -19
- data/spec/unit/controller_filters_spec.rb +5 -5
- data/spec/unit/csv_builder_spec.rb +7 -4
- data/spec/unit/filters/active_spec.rb +1 -8
- data/spec/unit/filters/filter_form_builder_spec.rb +2 -3
- data/spec/unit/filters/resource_spec.rb +3 -4
- data/spec/unit/form_builder_spec.rb +39 -11
- data/spec/unit/namespace/register_page_spec.rb +1 -1
- data/spec/unit/pretty_format_spec.rb +39 -35
- data/spec/unit/resource/attributes_spec.rb +50 -0
- data/spec/unit/resource/includes_spec.rb +1 -1
- data/spec/unit/resource/ordering_spec.rb +1 -1
- data/spec/unit/resource/routes_spec.rb +2 -2
- data/spec/unit/resource_controller/data_access_spec.rb +51 -10
- data/spec/unit/resource_controller/decorators_spec.rb +2 -2
- data/spec/unit/resource_controller/sidebars_spec.rb +3 -3
- data/spec/unit/resource_controller_spec.rb +16 -5
- data/spec/unit/resource_spec.rb +12 -38
- data/spec/unit/routing_spec.rb +2 -2
- data/spec/unit/view_helpers/breadcrumbs_spec.rb +36 -1
- data/spec/unit/view_helpers/display_helper_spec.rb +17 -2
- data/spec/unit/view_helpers/fields_for_spec.rb +1 -1
- data/spec/unit/view_helpers/form_helper_spec.rb +3 -3
- data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +2 -2
- data/spec/unit/views/components/attributes_table_spec.rb +2 -2
- data/spec/unit/views/components/index_list_spec.rb +1 -1
- data/spec/unit/views/components/paginated_collection_spec.rb +4 -4
- data/spec/unit/views/components/table_for_spec.rb +1 -1
- data/spec/unit/views/components/unsupported_browser_spec.rb +1 -1
- data/spec/unit/views/pages/form_spec.rb +4 -1
- data/spec/unit/views/pages/index_spec.rb +1 -1
- data/spec/unit/views/pages/show_spec.rb +2 -3
- data/tasks/lint.rake +8 -0
- metadata +22 -29
- data/features/step_definitions/symbol_leak_steps.rb +0 -3
- data/features/symbol_leak.feature +0 -35
- data/gemfiles/rails_32.gemfile +0 -54
- data/gemfiles/rails_40.gemfile +0 -53
- data/gemfiles/rails_41.gemfile +0 -53
- data/spec/support/deferred_garbage_collection.rb +0 -19
@@ -32,11 +32,11 @@ RSpec.describe ActiveAdmin::ResourceController::Decorators do
|
|
32
32
|
context 'with form' do
|
33
33
|
let(:action) { 'update' }
|
34
34
|
|
35
|
-
it "does not decorate when :decorate is set to false" do
|
35
|
+
it "does not decorate when :decorate is set to false" do
|
36
36
|
form = double
|
37
37
|
allow(form).to receive(:options).and_return(decorate: false)
|
38
38
|
allow(active_admin_config).to receive(:get_page_presenter).and_return(form)
|
39
|
-
is_expected.not_to be_kind_of(PostDecorator)
|
39
|
+
is_expected.not_to be_kind_of(PostDecorator)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -23,10 +23,10 @@ RSpec.describe ActiveAdmin::ResourceController::Sidebars, type: :controller do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
context 'with skip_sidebar!
|
26
|
+
context 'with skip_sidebar! before_action' do
|
27
27
|
include_context 'with post config' do
|
28
28
|
let(:post_config) do
|
29
|
-
ActiveAdmin.register(Post) {
|
29
|
+
ActiveAdmin.register(Post) { before_action :skip_sidebar! }
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -34,4 +34,4 @@ RSpec.describe ActiveAdmin::ResourceController::Sidebars, type: :controller do
|
|
34
34
|
expect(controller.instance_variable_get(:@skip_sidebar)).to eq true
|
35
35
|
end
|
36
36
|
end
|
37
|
-
end
|
37
|
+
end
|
@@ -156,11 +156,12 @@ RSpec.describe "A specific resource controller", type: :controller do
|
|
156
156
|
|
157
157
|
describe 'retrieving the resource' do
|
158
158
|
let(:post) { Post.new title: "An incledibly unique Post Title" }
|
159
|
+
let(:http_params){ { id: '1' } }
|
159
160
|
|
160
161
|
before do
|
161
162
|
allow(Post).to receive(:find).and_return(post)
|
162
163
|
controller.class_eval { public :resource }
|
163
|
-
allow(controller).to receive(:params).and_return(
|
164
|
+
allow(controller).to receive(:params).and_return( ActionController::Parameters.new(http_params) )
|
164
165
|
end
|
165
166
|
|
166
167
|
subject { controller.resource }
|
@@ -220,13 +221,17 @@ RSpec.describe "A specific resource controller", type: :controller do
|
|
220
221
|
describe "performing batch_action" do
|
221
222
|
let(:batch_action) { ActiveAdmin::BatchAction.new :flag, "Flag", &batch_action_block }
|
222
223
|
let(:batch_action_block) { proc { } }
|
224
|
+
let(:params) { ActionController::Parameters.new(http_params) }
|
225
|
+
|
223
226
|
before do
|
224
227
|
allow(controller.class.active_admin_config).to receive(:batch_actions).and_return([batch_action])
|
228
|
+
allow(controller).to receive(:params) { params }
|
225
229
|
end
|
226
230
|
|
227
231
|
describe "when params batch_action matches existing BatchAction" do
|
228
|
-
|
229
|
-
|
232
|
+
|
233
|
+
let(:http_params) do
|
234
|
+
{ batch_action: "flag", collection_selection: ["1"] }
|
230
235
|
end
|
231
236
|
|
232
237
|
it "should call the block with args" do
|
@@ -241,8 +246,11 @@ RSpec.describe "A specific resource controller", type: :controller do
|
|
241
246
|
end
|
242
247
|
|
243
248
|
describe "when params batch_action doesn't match a BatchAction" do
|
249
|
+
let(:http_params) do
|
250
|
+
{ batch_action: "derp", collection_selection: ["1"] }
|
251
|
+
end
|
252
|
+
|
244
253
|
it "should raise an error" do
|
245
|
-
allow(controller).to receive(:params) { { batch_action: "derp", collection_selection: ["1"] } }
|
246
254
|
expect {
|
247
255
|
controller.batch_action
|
248
256
|
}.to raise_error("Couldn't find batch action \"derp\"")
|
@@ -250,8 +258,11 @@ RSpec.describe "A specific resource controller", type: :controller do
|
|
250
258
|
end
|
251
259
|
|
252
260
|
describe "when params batch_action is blank" do
|
261
|
+
let(:http_params) do
|
262
|
+
{ collection_selection: ["1"] }
|
263
|
+
end
|
264
|
+
|
253
265
|
it "should raise an error" do
|
254
|
-
allow(controller).to receive(:params) { { collection_selection: ["1"] } }
|
255
266
|
expect {
|
256
267
|
controller.batch_action
|
257
268
|
}.to raise_error("Couldn't find batch action \"\"")
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -85,10 +85,10 @@ module ActiveAdmin
|
|
85
85
|
expect(config.belongs_to_config).to_not eq nil
|
86
86
|
end
|
87
87
|
|
88
|
-
it "should set the target menu to the belongs to target" do
|
88
|
+
it "should not set the target menu to the belongs to target" do
|
89
89
|
expect(config.navigation_menu_name).to eq ActiveAdmin::DEFAULT_MENU
|
90
90
|
config.belongs_to :posts
|
91
|
-
expect(config.navigation_menu_name).to eq
|
91
|
+
expect(config.navigation_menu_name).to eq ActiveAdmin::DEFAULT_MENU
|
92
92
|
end
|
93
93
|
|
94
94
|
end
|
@@ -197,7 +197,7 @@ module ActiveAdmin
|
|
197
197
|
describe "#csv_builder" do
|
198
198
|
context "when no csv builder set" do
|
199
199
|
it "should return a default column builder with id and content columns" do
|
200
|
-
expect(config.csv_builder.exec_columns.size).to eq
|
200
|
+
expect(config.csv_builder.exec_columns.size).to eq @config.content_columns.size + 1
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
@@ -234,13 +234,8 @@ module ActiveAdmin
|
|
234
234
|
let(:resource) { namespace.register(Post) }
|
235
235
|
let(:post) { double }
|
236
236
|
before do
|
237
|
-
|
238
|
-
|
239
|
-
allow(Post).to receive(:find_by).with("id" => "54321") { nil }
|
240
|
-
else
|
241
|
-
allow(Post).to receive(:find_by_id).with("12345") { post }
|
242
|
-
allow(Post).to receive(:find_by_id).with("54321") { nil }
|
243
|
-
end
|
237
|
+
allow(Post).to receive(:find_by).with("id" => "12345") { post }
|
238
|
+
allow(Post).to receive(:find_by).with("id" => "54321") { nil }
|
244
239
|
end
|
245
240
|
|
246
241
|
it 'can find the resource' do
|
@@ -262,13 +257,8 @@ module ActiveAdmin
|
|
262
257
|
let(:different_post) { double }
|
263
258
|
before do
|
264
259
|
allow(Post).to receive(:primary_key).and_return 'something_else'
|
265
|
-
|
266
|
-
allow(Post).to receive(:find_by).
|
260
|
+
allow(Post).to receive(:find_by).
|
267
261
|
with("something_else" => "55555") { different_post }
|
268
|
-
else
|
269
|
-
allow(Post).to receive(:find_by_something_else).
|
270
|
-
with("55555") { different_post }
|
271
|
-
end
|
272
262
|
end
|
273
263
|
|
274
264
|
it 'can find the post by the custom primary key' do
|
@@ -301,36 +291,20 @@ module ActiveAdmin
|
|
301
291
|
end
|
302
292
|
end.new
|
303
293
|
}
|
304
|
-
let(:resource) { ActiveAdmin::ResourceDSL.new(double
|
294
|
+
let(:resource) { ActiveAdmin::ResourceDSL.new(double) }
|
305
295
|
|
306
296
|
before do
|
307
297
|
expect(resource).to receive(:controller).and_return(controller)
|
308
298
|
end
|
309
299
|
|
310
|
-
context "
|
300
|
+
context "actions" do
|
311
301
|
[
|
312
|
-
:
|
313
|
-
:
|
314
|
-
:
|
302
|
+
:before_action, :skip_before_action,
|
303
|
+
:after_action, :skip_after_action,
|
304
|
+
:around_action, :skip_action
|
315
305
|
].each do |method|
|
316
306
|
it "delegates #{method}" do
|
317
|
-
|
318
|
-
expected.sub! 'filter', 'action' if ActiveAdmin::Dependency.rails >= 4
|
319
|
-
expect(resource.send(method)).to eq "called #{expected}"
|
320
|
-
end
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
if ActiveAdmin::Dependency.rails >= 4
|
325
|
-
context "actions" do
|
326
|
-
[
|
327
|
-
:before_action, :skip_before_action,
|
328
|
-
:after_action, :skip_after_action,
|
329
|
-
:around_action, :skip_action
|
330
|
-
].each do |method|
|
331
|
-
it "delegates #{method}" do
|
332
|
-
expect(resource.send(method)).to eq "called #{method}"
|
333
|
-
end
|
307
|
+
expect(resource.send(method)).to eq "called #{method}"
|
334
308
|
end
|
335
309
|
end
|
336
310
|
end
|
data/spec/unit/routing_spec.rb
CHANGED
@@ -145,7 +145,7 @@ RSpec.describe ActiveAdmin, "Routing", type: :routing do
|
|
145
145
|
end
|
146
146
|
|
147
147
|
it "should route the nested show path" do
|
148
|
-
expect(admin_user_post_path(1,2)).to eq "/admin/users/1/posts/2"
|
148
|
+
expect(admin_user_post_path(1, 2)).to eq "/admin/users/1/posts/2"
|
149
149
|
end
|
150
150
|
|
151
151
|
it "should route the nested new path" do
|
@@ -153,7 +153,7 @@ RSpec.describe ActiveAdmin, "Routing", type: :routing do
|
|
153
153
|
end
|
154
154
|
|
155
155
|
it "should route the nested edit path" do
|
156
|
-
expect(edit_admin_user_post_path(1,2)).to eq "/admin/users/1/posts/2/edit"
|
156
|
+
expect(edit_admin_user_post_path(1, 2)).to eq "/admin/users/1/posts/2/edit"
|
157
157
|
end
|
158
158
|
|
159
159
|
context "with collection action" do
|
@@ -129,7 +129,7 @@ RSpec.describe "Breadcrumbs" do
|
|
129
129
|
context "when User.find(4e24d6249ccf967313000000) does exist" do
|
130
130
|
before do
|
131
131
|
display_name = double(display_name: 'Hello :)')
|
132
|
-
allow(user_config).to receive(:find_resource).and_return(display_name)
|
132
|
+
allow(user_config).to receive(:find_resource).and_return(display_name)
|
133
133
|
end
|
134
134
|
it "should have a link to /admin/users/4e24d6249ccf967313000000 using display name" do
|
135
135
|
expect(trail[2][:name]).to eq "Hello :)"
|
@@ -138,6 +138,41 @@ RSpec.describe "Breadcrumbs" do
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
+
context "when path '/admin/users/2b2f0fc2-9a0d-41b8-b39d-aa21963aaee4/posts'" do
|
142
|
+
let(:path) { "/admin/users/2b2f0fc2-9a0d-41b8-b39d-aa21963aaee4/posts" }
|
143
|
+
|
144
|
+
it "should have 3 items" do
|
145
|
+
expect(trail.size).to eq 3
|
146
|
+
end
|
147
|
+
it "should have a link to /admin" do
|
148
|
+
expect(trail[0][:name]).to eq "Admin"
|
149
|
+
expect(trail[0][:path]).to eq "/admin"
|
150
|
+
end
|
151
|
+
it "should have a link to /admin/users" do
|
152
|
+
expect(trail[1][:name]).to eq "Users"
|
153
|
+
expect(trail[1][:path]).to eq "/admin/users"
|
154
|
+
end
|
155
|
+
|
156
|
+
context "when User.find(2b2f0fc2-9a0d-41b8-b39d-aa21963aaee4) doesn't exist" do
|
157
|
+
before { allow(user_config).to receive(:find_resource) }
|
158
|
+
it "should have a link to /admin/users/2b2f0fc2-9a0d-41b8-b39d-aa21963aaee4" do
|
159
|
+
expect(trail[2][:name]).to eq "2b2f0fc2-9a0d-41b8-b39d-aa21963aaee4".titlecase
|
160
|
+
expect(trail[2][:path]).to eq "/admin/users/2b2f0fc2-9a0d-41b8-b39d-aa21963aaee4"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context "when User.find(2b2f0fc2-9a0d-41b8-b39d-aa21963aaee4) does exist" do
|
165
|
+
before do
|
166
|
+
display_name = double(display_name: 'Hello :)')
|
167
|
+
allow(user_config).to receive(:find_resource).and_return(display_name)
|
168
|
+
end
|
169
|
+
it "should have a link to /admin/users/2b2f0fc2-9a0d-41b8-b39d-aa21963aaee4 using display name" do
|
170
|
+
expect(trail[2][:name]).to eq "Hello :)"
|
171
|
+
expect(trail[2][:path]).to eq "/admin/users/2b2f0fc2-9a0d-41b8-b39d-aa21963aaee4"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
141
176
|
context "when path '/admin/users/1/coments/1'" do
|
142
177
|
let(:path) { "/admin/users/1/posts/1" }
|
143
178
|
|
@@ -151,10 +151,10 @@ RSpec.describe ActiveAdmin::ViewHelpers::DisplayHelper do
|
|
151
151
|
expect(value).to eq :right
|
152
152
|
end
|
153
153
|
|
154
|
-
it 'auto-links ActiveRecord records
|
154
|
+
it 'auto-links ActiveRecord records by association' do
|
155
155
|
post = Post.create! author: User.new
|
156
156
|
|
157
|
-
value = format_attribute post, :
|
157
|
+
value = format_attribute post, :author
|
158
158
|
|
159
159
|
expect(value).to match /<a href="\/admin\/users\/\d+"> <\/a>/
|
160
160
|
end
|
@@ -176,5 +176,20 @@ RSpec.describe ActiveAdmin::ViewHelpers::DisplayHelper do
|
|
176
176
|
|
177
177
|
expect(value.to_s).to eq "<span class=\"status_tag yes\">Yes</span>\n"
|
178
178
|
end
|
179
|
+
|
180
|
+
it 'calls status_tag for boolean non-database values' do
|
181
|
+
post = Post.new
|
182
|
+
post.define_singleton_method(:true_method) do
|
183
|
+
true
|
184
|
+
end
|
185
|
+
post.define_singleton_method(:false_method) do
|
186
|
+
false
|
187
|
+
end
|
188
|
+
true_value = format_attribute post, :true_method
|
189
|
+
expect(true_value.to_s).to eq "<span class=\"status_tag yes\">Yes</span>\n"
|
190
|
+
false_value = format_attribute post, :false_method
|
191
|
+
expect(false_value.to_s).to eq "<span class=\"status_tag no\">No</span>\n"
|
192
|
+
end
|
193
|
+
|
179
194
|
end
|
180
195
|
end
|
@@ -25,17 +25,17 @@ RSpec.describe ActiveAdmin::ViewHelpers::FormHelper do
|
|
25
25
|
let(:view) { action_view }
|
26
26
|
|
27
27
|
it "should render hidden field tags for params" do
|
28
|
-
html = Capybara.string view.hidden_field_tags_for(scope: "All", filter: "None")
|
28
|
+
html = Capybara.string view.hidden_field_tags_for(ActionController::Parameters.new(scope: "All", filter: "None"))
|
29
29
|
expect(html).to have_selector("input#hidden_active_admin_scope[name=scope][type=hidden][value=All]")
|
30
30
|
expect(html).to have_selector("input#hidden_active_admin_filter[name=filter][type=hidden][value=None]")
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should generate not default id for hidden input" do
|
34
|
-
expect(view.hidden_field_tags_for(scope: "All")[/id="([^"]+)"/, 1]).to_not eq "scope"
|
34
|
+
expect(view.hidden_field_tags_for(ActionController::Parameters.new(scope: "All"))[/id="([^"]+)"/, 1]).to_not eq "scope"
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should filter out the field passed via the option :except" do
|
38
|
-
html = Capybara.string view.hidden_field_tags_for(
|
38
|
+
html = Capybara.string view.hidden_field_tags_for(ActionController::Parameters.new(scope: "All", filter: "None"), except: :filter)
|
39
39
|
expect(html).to have_selector("input#hidden_active_admin_scope[name=scope][type=hidden][value=All]")
|
40
40
|
end
|
41
41
|
end
|
@@ -55,7 +55,7 @@ RSpec.describe MethodOrProcHelper do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
expect {
|
58
|
-
context.call_method_or_proc_on(receiver,test_proc)
|
58
|
+
context.call_method_or_proc_on(receiver, test_proc)
|
59
59
|
}.to raise_error("Success!")
|
60
60
|
end
|
61
61
|
|
@@ -81,7 +81,7 @@ RSpec.describe MethodOrProcHelper do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
expect {
|
84
|
-
context.call_method_or_proc_on(receiver,test_proc, exec: false)
|
84
|
+
context.call_method_or_proc_on(receiver, test_proc, exec: false)
|
85
85
|
}.to raise_error("Success!")
|
86
86
|
end
|
87
87
|
|
@@ -139,7 +139,7 @@ RSpec.describe ActiveAdmin::Views::AttributesTable do
|
|
139
139
|
end
|
140
140
|
it 'should call the association if one exists' do
|
141
141
|
table = render_arbre_component assigns do
|
142
|
-
attributes_table_for post, :
|
142
|
+
attributes_table_for post, :author
|
143
143
|
end
|
144
144
|
expect(table.find_by_tag('th').first.content).to eq 'Author'
|
145
145
|
expect(table.find_by_tag('td').first.content).to eq 'John Doe'
|
@@ -256,7 +256,7 @@ RSpec.describe ActiveAdmin::Views::AttributesTable do
|
|
256
256
|
context "when using an Array of Hashes" do
|
257
257
|
let(:table) do
|
258
258
|
render_arbre_component nil, helpers do
|
259
|
-
attributes_table_for [{foo: 1},{foo: 2}] do
|
259
|
+
attributes_table_for [{foo: 1}, {foo: 2}] do
|
260
260
|
row :foo
|
261
261
|
end
|
262
262
|
end
|
@@ -15,7 +15,7 @@ RSpec.describe ActiveAdmin::Views::IndexList do
|
|
15
15
|
helpers = mock_action_view
|
16
16
|
allow(helpers).to receive(:url_for) { |url| "/?#{ url.to_query }" }
|
17
17
|
allow(helpers.request).to receive(:query_parameters).and_return as: "table", q: { title_contains: "terms" }
|
18
|
-
allow(helpers).to receive(:params).and_return
|
18
|
+
allow(helpers).to receive(:params).and_return(ActionController::Parameters.new(as: "table", q: { title_contains: "terms" }))
|
19
19
|
allow(helpers).to receive(:collection).and_return(collection)
|
20
20
|
helpers
|
21
21
|
end
|
@@ -189,7 +189,7 @@ RSpec.describe ActiveAdmin::Views::PaginatedCollection do
|
|
189
189
|
end
|
190
190
|
|
191
191
|
it "should display proper message (including number and not hash)" do
|
192
|
-
expect(pagination.find_by_class('pagination_information').first.content.gsub(' ',' ')).
|
192
|
+
expect(pagination.find_by_class('pagination_information').first.content.gsub(' ', ' ')).
|
193
193
|
to eq "Displaying posts <b>1 - 2</b> of <b>3</b> in total"
|
194
194
|
end
|
195
195
|
end
|
@@ -200,7 +200,7 @@ RSpec.describe ActiveAdmin::Views::PaginatedCollection do
|
|
200
200
|
end
|
201
201
|
|
202
202
|
it "should show the proper item counts" do
|
203
|
-
expect(pagination.find_by_class('pagination_information').first.content.gsub(' ',' ')).
|
203
|
+
expect(pagination.find_by_class('pagination_information').first.content.gsub(' ', ' ')).
|
204
204
|
to eq "Displaying posts <b>61 - 81</b> of <b>81</b> in total"
|
205
205
|
end
|
206
206
|
end
|
@@ -214,7 +214,7 @@ RSpec.describe ActiveAdmin::Views::PaginatedCollection do
|
|
214
214
|
it "should not show the total item counts" do
|
215
215
|
expect(collection).not_to receive(:total_pages)
|
216
216
|
pagination = paginated_collection(collection, pagination_total: false)
|
217
|
-
info = pagination.find_by_class('pagination_information').first.content.gsub(' ',' ')
|
217
|
+
info = pagination.find_by_class('pagination_information').first.content.gsub(' ', ' ')
|
218
218
|
expect(info).to eq "Displaying posts <b>1 - 30</b>"
|
219
219
|
end
|
220
220
|
end
|
@@ -223,7 +223,7 @@ RSpec.describe ActiveAdmin::Views::PaginatedCollection do
|
|
223
223
|
let(:pagination) { paginated_collection(collection, pagination_total: true) }
|
224
224
|
|
225
225
|
it "should show the total item counts" do
|
226
|
-
info = pagination.find_by_class('pagination_information').first.content.gsub(' ',' ')
|
226
|
+
info = pagination.find_by_class('pagination_information').first.content.gsub(' ', ' ')
|
227
227
|
expect(info).to eq "Displaying posts <b>1 - 30</b> of <b>256</b> in total"
|
228
228
|
end
|
229
229
|
end
|
@@ -258,7 +258,7 @@ RSpec.describe ActiveAdmin::Views::TableFor do
|
|
258
258
|
context "when using an Array of Hashes" do
|
259
259
|
let(:table) do
|
260
260
|
render_arbre_component nil, helpers do
|
261
|
-
table_for [{foo: 1},{foo: 2}] do
|
261
|
+
table_for [{foo: 1}, {foo: 2}] do
|
262
262
|
column :foo
|
263
263
|
end
|
264
264
|
end
|
@@ -14,7 +14,7 @@ RSpec.describe ActiveAdmin::Views::UnsupportedBrowser do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should render the panel" do
|
17
|
-
expect(I18n).to receive(:t).and_return("headline", "recommendation" ,"turn_off_compatibility_view")
|
17
|
+
expect(I18n).to receive(:t).and_return("headline", "recommendation" , "turn_off_compatibility_view")
|
18
18
|
expect(build_panel.content.gsub(/\s+/, "")).to eq "<h1>headline</h1><p>recommendation</p><p>turn_off_compatibility_view</p>"
|
19
19
|
end
|
20
20
|
|
@@ -4,7 +4,9 @@ RSpec.describe ActiveAdmin::Views::Pages::Form do
|
|
4
4
|
describe "#title" do
|
5
5
|
let!(:application){ ActiveAdmin::Application.new }
|
6
6
|
let(:namespace){ ActiveAdmin::Namespace.new(application, "Admin") }
|
7
|
-
let!(:
|
7
|
+
let!(:http_params){ { controller: "UsersController", action: "edit" } }
|
8
|
+
let!(:params) { ActionController::Parameters.new(http_params) }
|
9
|
+
|
8
10
|
let(:helpers) do
|
9
11
|
helpers = mock_action_view
|
10
12
|
allow(helpers).to receive(:active_admin_config).and_return(namespace.register(Post))
|
@@ -18,6 +20,7 @@ RSpec.describe ActiveAdmin::Views::Pages::Form do
|
|
18
20
|
|
19
21
|
context "when :title is set" do
|
20
22
|
it "should show the set page title" do
|
23
|
+
|
21
24
|
page = ActiveAdmin::Views::Pages::Form.new(arbre_context)
|
22
25
|
expect(page).to receive(:resource)
|
23
26
|
expect(page).to receive(:form_presenter).twice.and_return({ title: "My Page Title" })
|
@@ -4,7 +4,7 @@ RSpec.describe ActiveAdmin::Views::Pages::Index do
|
|
4
4
|
describe "#title" do
|
5
5
|
let!(:application){ ActiveAdmin::Application.new }
|
6
6
|
let(:namespace){ ActiveAdmin::Namespace.new(application, "Admin") }
|
7
|
-
let!(:params){
|
7
|
+
let!(:params){ ActionController::Parameters.new(controller: "UsersController", action: "edit") }
|
8
8
|
let(:helpers) do
|
9
9
|
helpers = mock_action_view
|
10
10
|
allow(helpers).to receive(:active_admin_config).and_return(namespace.register(Post))
|