activeadmin 1.0.0.pre2 → 1.0.0.pre3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.hound.yml +7 -4
- data/.travis.yml +17 -15
- data/CHANGELOG.md +5 -1
- data/CODE_OF_CONDUCT.md +22 -0
- data/Gemfile +26 -12
- data/README.md +24 -4
- data/activeadmin.gemspec +1 -0
- data/app/assets/javascripts/active_admin/base.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/initializers/batch_actions.js.coffee +7 -0
- data/app/assets/javascripts/active_admin/initializers/datepicker.js.coffee +10 -0
- data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +15 -0
- data/app/assets/javascripts/active_admin/initializers/tabs.js.coffee +3 -0
- data/app/assets/javascripts/active_admin/lib/batch_actions.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/lib/dropdown-menu.js.coffee +1 -1
- data/app/assets/stylesheets/active_admin/_forms.scss +1 -1
- data/config/locales/ar.yml +47 -43
- data/config/locales/de.yml +2 -1
- data/config/locales/en.yml +2 -1
- data/config/locales/es-MX.yml +3 -3
- data/config/locales/es.yml +5 -4
- data/config/locales/fr.yml +2 -1
- data/config/locales/hu.yml +1 -1
- data/config/locales/id.yml +2 -1
- data/config/locales/it.yml +19 -0
- data/config/locales/ja.yml +2 -1
- data/config/locales/ko.yml +2 -1
- data/config/locales/nb.yml +6 -1
- data/config/locales/nl.yml +1 -1
- data/config/locales/pt-BR.yml +5 -1
- data/config/locales/ru.yml +4 -3
- data/config/locales/sv-SE.yml +3 -2
- data/config/locales/tr.yml +83 -44
- data/config/locales/uk.yml +13 -12
- data/config/locales/zh-CN.yml +2 -1
- data/config/locales/zh-TW.yml +10 -1
- data/cucumber.yml +1 -1
- data/docs/0-installation.md +24 -10
- data/docs/1-general-configuration.md +22 -0
- data/docs/12-arbre-components.md +1 -1
- data/docs/13-authorization-adapter.md +1 -1
- data/docs/14-gotchas.md +11 -3
- data/docs/2-resource-customization.md +16 -3
- data/docs/3-index-pages.md +1 -1
- data/docs/3-index-pages/index-as-table.md +13 -1
- data/docs/4-csv-format.md +19 -0
- data/docs/5-forms.md +14 -2
- data/docs/6-show-pages.md +1 -1
- data/features/decorators.feature +2 -0
- data/features/development_reloading.feature +1 -1
- data/features/edit_page.feature +4 -4
- data/features/index/batch_actions.feature +13 -0
- data/features/index/page_title.feature +2 -1
- data/features/new_page.feature +4 -4
- data/features/renamed_resource.feature +1 -1
- data/features/show/default_content.feature +1 -1
- data/features/show/page_title.feature +2 -1
- data/features/step_definitions/attribute_steps.rb +2 -2
- data/features/step_definitions/factory_steps.rb +2 -2
- data/features/step_definitions/filter_steps.rb +2 -2
- data/features/step_definitions/format_steps.rb +1 -1
- data/features/sti_resource.feature +2 -2
- data/features/strong_parameters.feature +3 -3
- data/features/support/env.rb +21 -4
- data/lib/active_admin/application.rb +11 -4
- data/lib/active_admin/authorization_adapter.rb +1 -1
- data/lib/active_admin/base_controller.rb +12 -2
- data/lib/active_admin/base_controller/authorization.rb +4 -7
- data/lib/active_admin/base_controller/menu.rb +5 -1
- data/lib/active_admin/batch_actions/controller.rb +0 -1
- data/lib/active_admin/batch_actions/resource_extension.rb +3 -2
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -0
- data/lib/active_admin/csv_builder.rb +18 -15
- data/lib/active_admin/dependency.rb +74 -1
- data/lib/active_admin/error.rb +1 -1
- data/lib/active_admin/filters/active.rb +4 -3
- data/lib/active_admin/filters/resource_extension.rb +7 -3
- data/lib/active_admin/generators/boilerplate.rb +8 -0
- data/lib/active_admin/inputs/filters/base.rb +3 -1
- data/lib/active_admin/inputs/filters/base/search_method_select.rb +3 -3
- data/lib/active_admin/inputs/filters/date_range_input.rb +2 -2
- data/lib/active_admin/inputs/filters/select_input.rb +3 -2
- data/lib/active_admin/orm/active_record/comments.rb +13 -8
- data/lib/active_admin/page_controller.rb +5 -1
- data/lib/active_admin/reloader.rb +25 -0
- data/lib/active_admin/resource/menu.rb +1 -1
- data/lib/active_admin/resource_controller/data_access.rb +33 -20
- data/lib/active_admin/resource_controller/decorators.rb +2 -2
- data/lib/active_admin/resource_controller/streaming.rb +7 -1
- data/lib/active_admin/resource_dsl.rb +15 -9
- data/lib/active_admin/router.rb +1 -1
- data/lib/active_admin/scope.rb +2 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers/display_helper.rb +31 -0
- data/lib/active_admin/view_helpers/fields_for.rb +3 -2
- data/lib/active_admin/views/components/attributes_table.rb +5 -23
- data/lib/active_admin/views/components/index_list.rb +1 -1
- data/lib/active_admin/views/components/paginated_collection.rb +3 -3
- data/lib/active_admin/views/components/site_title.rb +1 -1
- data/lib/active_admin/views/components/table_for.rb +8 -27
- data/lib/active_admin/views/index_as_grid.rb +2 -2
- data/lib/active_admin/views/index_as_table.rb +24 -2
- data/lib/active_admin/views/pages/base.rb +1 -1
- data/lib/active_admin/views/pages/form.rb +6 -2
- data/lib/active_admin/views/title_bar.rb +1 -1
- data/lib/generators/active_admin/assets/templates/active_admin.scss +1 -1
- data/lib/generators/active_admin/install/install_generator.rb +1 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +14 -4
- data/lib/generators/active_admin/resource/templates/admin.rb +8 -2
- data/lib/ransack_ext.rb +8 -0
- data/script/local +15 -6
- data/spec/rails_helper.rb +12 -1
- data/spec/requests/javascript_spec.rb +15 -13
- data/spec/requests/stylesheets_spec.rb +1 -1
- data/spec/support/detect_rails_version.rb +1 -1
- data/spec/support/rails_template.rb +117 -104
- data/spec/support/rails_template_with_data.rb +5 -9
- data/spec/support/templates/admin/stores.rb +1 -1
- data/spec/unit/action_builder_spec.rb +58 -56
- data/spec/unit/authorization/authorization_adapter_spec.rb +5 -5
- data/spec/unit/authorization/index_overriding_spec.rb +2 -1
- data/spec/unit/auto_link_spec.rb +1 -1
- data/spec/unit/batch_actions/resource_spec.rb +2 -2
- data/spec/unit/batch_actions/settings_spec.rb +13 -13
- data/spec/unit/comments_spec.rb +5 -5
- data/spec/unit/csv_builder_spec.rb +59 -0
- data/spec/unit/dsl_spec.rb +1 -1
- data/spec/unit/filters/filter_form_builder_spec.rb +5 -4
- data/spec/unit/filters/resource_spec.rb +7 -0
- data/spec/unit/form_builder_spec.rb +4 -1
- data/spec/unit/generators/install_spec.rb +4 -4
- data/spec/unit/helpers/collection_spec.rb +4 -4
- data/spec/unit/menu_collection_spec.rb +3 -3
- data/spec/unit/namespace/register_page_spec.rb +17 -18
- data/spec/unit/namespace/register_resource_spec.rb +20 -21
- data/spec/unit/namespace_spec.rb +4 -4
- data/spec/unit/pundit_adapter_spec.rb +3 -3
- data/spec/unit/resource/action_items_spec.rb +1 -1
- data/spec/unit/resource/naming_spec.rb +1 -1
- data/spec/unit/resource/routes_spec.rb +6 -2
- data/spec/unit/resource/scopes_spec.rb +2 -2
- data/spec/unit/resource_controller/decorators_spec.rb +11 -0
- data/spec/unit/resource_controller/sidebars_spec.rb +17 -24
- data/spec/unit/resource_spec.rb +14 -12
- data/spec/unit/routing_spec.rb +19 -14
- data/spec/unit/scope_spec.rb +28 -33
- data/spec/unit/view_helpers/display_helper_spec.rb +165 -0
- data/spec/unit/view_helpers/download_format_links_helper_spec.rb +9 -9
- data/spec/unit/views/components/attributes_table_spec.rb +1 -1
- data/spec/unit/views/components/blank_slate_spec.rb +3 -3
- data/spec/unit/views/components/index_table_for_spec.rb +82 -1
- data/spec/unit/views/components/paginated_collection_spec.rb +0 -1
- data/spec/unit/views/components/table_for_spec.rb +13 -8
- data/spec/unit/views/components/unsupported_browser_spec.rb +2 -8
- data/spec/unit/views/index_as_blog_spec.rb +76 -0
- data/spec/unit/views/pages/form_spec.rb +9 -0
- data/tasks/test.rake +13 -5
- metadata +27 -10
- data/app/assets/javascripts/active_admin/application.js.coffee +0 -37
- data/spec/support/templates/cucumber.rb +0 -24
- data/spec/support/templates/cucumber_with_reloading.rb +0 -5
- data/spec/unit/view_helpers/display_name_spec.rb +0 -71
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
# Use the default
|
|
2
1
|
apply File.expand_path("../rails_template.rb", __FILE__)
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
%w{ Post User Category }.each do |type|
|
|
3
|
+
%w{Post User Category}.each do |type|
|
|
6
4
|
generate :'active_admin:resource', type
|
|
7
5
|
end
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
inject_into_file 'app/admin/post.rb', <<-RUBY, after: "ActiveAdmin.register Post do\n"
|
|
10
8
|
scope :all, default: true
|
|
11
9
|
|
|
12
10
|
scope :drafts do |posts|
|
|
@@ -24,11 +22,9 @@ scopes = <<-EOF
|
|
|
24
22
|
scope :my_posts do |posts|
|
|
25
23
|
posts.where(author_id: current_admin_user.id)
|
|
26
24
|
end
|
|
27
|
-
|
|
28
|
-
inject_into_file 'app/admin/posts.rb', scopes , after: "ActiveAdmin.register Post do\n"
|
|
25
|
+
RUBY
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
append_file "db/seeds.rb", <<-EOF
|
|
27
|
+
append_file "db/seeds.rb", "\n\n" + <<-RUBY.strip_heredoc
|
|
32
28
|
users = ["Jimi Hendrix", "Jimmy Page", "Yngwie Malmsteen", "Eric Clapton", "Kirk Hammett"].collect do |name|
|
|
33
29
|
first, last = name.split(" ")
|
|
34
30
|
User.create! first_name: first,
|
|
@@ -54,6 +50,6 @@ append_file "db/seeds.rb", <<-EOF
|
|
|
54
50
|
author: user,
|
|
55
51
|
starred: true
|
|
56
52
|
end
|
|
57
|
-
|
|
53
|
+
RUBY
|
|
58
54
|
|
|
59
55
|
rake 'db:seed'
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
require 'rails_helper'
|
|
2
2
|
|
|
3
|
-
describe 'defining
|
|
3
|
+
describe 'defining actions from registration blocks', type: :controller do
|
|
4
|
+
let(:klass){ Admin::PostsController }
|
|
5
|
+
render_views # https://github.com/rspec/rspec-rails/issues/860
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
before do
|
|
8
|
+
@controller = klass.new
|
|
9
|
+
end
|
|
6
10
|
|
|
7
|
-
describe
|
|
11
|
+
describe 'creates a member action' do
|
|
8
12
|
before do
|
|
9
13
|
action!
|
|
10
14
|
reload_routes!
|
|
11
15
|
end
|
|
12
16
|
|
|
13
17
|
after(:each) do
|
|
14
|
-
|
|
18
|
+
klass.clear_member_actions!
|
|
15
19
|
end
|
|
16
20
|
|
|
17
|
-
context
|
|
21
|
+
context 'with a block' do
|
|
18
22
|
let(:action!) do
|
|
19
23
|
ActiveAdmin.register Post do
|
|
20
24
|
member_action :comment do
|
|
@@ -23,51 +27,61 @@ describe 'defining new actions from registration blocks' do
|
|
|
23
27
|
end
|
|
24
28
|
end
|
|
25
29
|
|
|
26
|
-
it
|
|
27
|
-
expect(
|
|
30
|
+
it 'should create a new public instance method' do
|
|
31
|
+
expect(klass.public_instance_methods.collect(&:to_s)).to include('comment')
|
|
28
32
|
end
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
|
|
34
|
+
it 'should add itself to the member actions config' do
|
|
35
|
+
expect(klass.active_admin_config.member_actions.size).to eq 1
|
|
31
36
|
end
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
|
|
38
|
+
it 'should create a new named route' do
|
|
39
|
+
expect(Rails.application.routes.url_helpers.methods.collect(&:to_s)).to include('comment_admin_post_path')
|
|
34
40
|
end
|
|
35
41
|
end
|
|
36
42
|
|
|
37
|
-
context
|
|
43
|
+
context 'without a block' do
|
|
38
44
|
let(:action!) do
|
|
39
45
|
ActiveAdmin.register Post do
|
|
40
46
|
member_action :comment
|
|
41
47
|
end
|
|
42
48
|
end
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
|
|
50
|
+
it 'should still generate a new empty action' do
|
|
51
|
+
expect(klass.public_instance_methods.collect(&:to_s)).to include('comment')
|
|
45
52
|
end
|
|
46
53
|
end
|
|
47
54
|
|
|
48
|
-
context
|
|
55
|
+
context 'with :title' do
|
|
49
56
|
let(:action!) do
|
|
50
57
|
ActiveAdmin.register Post do
|
|
51
|
-
member_action :comment, title:
|
|
58
|
+
member_action :comment, title: 'My Awesome Comment' do
|
|
59
|
+
render json: {a: 2}
|
|
60
|
+
end
|
|
52
61
|
end
|
|
53
62
|
end
|
|
54
63
|
|
|
55
|
-
|
|
64
|
+
it 'sets the page title' do
|
|
65
|
+
params = {id: 1}
|
|
66
|
+
params = {params: params} if ActiveAdmin::Dependency.rails5?
|
|
67
|
+
get :comment, params
|
|
56
68
|
|
|
57
|
-
|
|
69
|
+
expect(controller.instance_variable_get(:@page_title)).to eq 'My Awesome Comment'
|
|
70
|
+
end
|
|
58
71
|
end
|
|
59
72
|
end
|
|
60
73
|
|
|
61
|
-
describe
|
|
74
|
+
describe 'creates a collection action' do
|
|
62
75
|
before do
|
|
63
76
|
action!
|
|
64
77
|
reload_routes!
|
|
65
78
|
end
|
|
79
|
+
|
|
66
80
|
after(:each) do
|
|
67
|
-
|
|
81
|
+
klass.clear_collection_actions!
|
|
68
82
|
end
|
|
69
83
|
|
|
70
|
-
context
|
|
84
|
+
context 'with a block' do
|
|
71
85
|
let(:action!) do
|
|
72
86
|
ActiveAdmin.register Post do
|
|
73
87
|
collection_action :comments do
|
|
@@ -75,58 +89,46 @@ describe 'defining new actions from registration blocks' do
|
|
|
75
89
|
end
|
|
76
90
|
end
|
|
77
91
|
end
|
|
78
|
-
|
|
79
|
-
|
|
92
|
+
|
|
93
|
+
it 'should create a public instance method' do
|
|
94
|
+
expect(klass.public_instance_methods.collect(&:to_s)).to include('comments')
|
|
80
95
|
end
|
|
81
|
-
|
|
82
|
-
|
|
96
|
+
|
|
97
|
+
it 'should add itself to the member actions config' do
|
|
98
|
+
expect(klass.active_admin_config.collection_actions.size).to eq 1
|
|
83
99
|
end
|
|
84
|
-
|
|
85
|
-
|
|
100
|
+
|
|
101
|
+
it 'should create a named route' do
|
|
102
|
+
expect(Rails.application.routes.url_helpers.methods.collect(&:to_s)).to include('comments_admin_posts_path')
|
|
86
103
|
end
|
|
87
104
|
end
|
|
88
|
-
|
|
105
|
+
|
|
106
|
+
context 'without a block' do
|
|
89
107
|
let(:action!) do
|
|
90
108
|
ActiveAdmin.register Post do
|
|
91
109
|
collection_action :comments
|
|
92
110
|
end
|
|
93
111
|
end
|
|
94
|
-
|
|
95
|
-
|
|
112
|
+
|
|
113
|
+
it 'should still generate a new empty action' do
|
|
114
|
+
expect(klass.public_instance_methods.collect(&:to_s)).to include('comments')
|
|
96
115
|
end
|
|
97
116
|
end
|
|
98
|
-
|
|
117
|
+
|
|
118
|
+
context 'with :title' do
|
|
99
119
|
let(:action!) do
|
|
100
120
|
ActiveAdmin.register Post do
|
|
101
|
-
collection_action :comments, title:
|
|
121
|
+
collection_action :comments, title: 'My Awesome Comments' do
|
|
122
|
+
render json: {a: 2}
|
|
123
|
+
end
|
|
102
124
|
end
|
|
103
125
|
end
|
|
104
126
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
it { is_expected.to set_page_title_to "My Awesome Comments", for: controller }
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def find_before_filter(controller, action)
|
|
112
|
-
finder = if ActiveAdmin::Dependency.rails? '>= 4.1.0'
|
|
113
|
-
->c { c.kind == :before && c.instance_variable_get(:@if) == ["action_name == '#{action}'"] }
|
|
114
|
-
else
|
|
115
|
-
->c { c.kind == :before && c.options[:only] == [action] }
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
controller._process_action_callbacks.detect &finder
|
|
119
|
-
end
|
|
127
|
+
it 'sets the page title' do
|
|
128
|
+
get :comments
|
|
120
129
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
filter.raw_filter.call
|
|
124
|
-
@actual = options[:for].instance_variable_get(:@page_title)
|
|
125
|
-
expect(@actual).to eq expected
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
failure_message do |filter|
|
|
129
|
-
message = "expected before_filter to set the @page_title to '#{expected}', but was '#{@actual}'"
|
|
130
|
+
expect(controller.instance_variable_get(:@page_title)).to eq 'My Awesome Comments'
|
|
131
|
+
end
|
|
130
132
|
end
|
|
131
133
|
end
|
|
132
134
|
end
|
|
@@ -7,7 +7,7 @@ describe ActiveAdmin::AuthorizationAdapter do
|
|
|
7
7
|
describe "#authorized?" do
|
|
8
8
|
|
|
9
9
|
it "should always return true" do
|
|
10
|
-
expect(adapter.authorized?(:read, "Resource")).to
|
|
10
|
+
expect(adapter.authorized?(:read, "Resource")).to eq true
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
end
|
|
@@ -41,19 +41,19 @@ describe ActiveAdmin::AuthorizationAdapter do
|
|
|
41
41
|
let(:adapter) { auth_class.new(double, double) }
|
|
42
42
|
|
|
43
43
|
it "should match against a class" do
|
|
44
|
-
expect(adapter.authorized?(:read, String)).to
|
|
44
|
+
expect(adapter.authorized?(:read, String)).to eq true
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it 'should match against an instance' do
|
|
48
|
-
expect(adapter.authorized?(:read, "String")).to
|
|
48
|
+
expect(adapter.authorized?(:read, "String")).to eq true
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it 'should not match a different class' do
|
|
52
|
-
expect(adapter.authorized?(:read, Hash)).to
|
|
52
|
+
expect(adapter.authorized?(:read, Hash)).to eq false
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it 'should not match a different instance' do
|
|
56
|
-
expect(adapter.authorized?(:read, {})).to
|
|
56
|
+
expect(adapter.authorized?(:read, {})).to eq false
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
end
|
|
@@ -5,7 +5,8 @@ describe Admin::PostsController, 'Index overriding', type: :controller do
|
|
|
5
5
|
controller.instance_eval do
|
|
6
6
|
def index
|
|
7
7
|
super do
|
|
8
|
-
render
|
|
8
|
+
render Dependency.rails.render_key => 'Rendered from passed block'
|
|
9
|
+
return
|
|
9
10
|
end
|
|
10
11
|
end
|
|
11
12
|
end
|
data/spec/unit/auto_link_spec.rb
CHANGED
|
@@ -12,7 +12,7 @@ describe ActiveAdmin::BatchActions::ResourceExtension do
|
|
|
12
12
|
|
|
13
13
|
it "should have the default action by default" do
|
|
14
14
|
expect(resource.batch_actions.size).to eq 1
|
|
15
|
-
expect(resource.batch_actions.first.sym == :destroy).to
|
|
15
|
+
expect(resource.batch_actions.first.sym == :destroy).to eq true
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
end
|
|
@@ -35,7 +35,7 @@ describe ActiveAdmin::BatchActions::ResourceExtension do
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "should store the block in the batch action" do
|
|
38
|
-
expect(resource.batch_actions.first.block).to_not
|
|
38
|
+
expect(resource.batch_actions.first.block).to_not eq nil
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
end
|
|
@@ -8,42 +8,42 @@ describe "Batch Actions Settings" do
|
|
|
8
8
|
it "should be disabled globally by default" do
|
|
9
9
|
# Note: the default initializer would set it to true
|
|
10
10
|
|
|
11
|
-
expect(app.batch_actions).to
|
|
12
|
-
expect(ns.batch_actions).to
|
|
13
|
-
expect(post_resource.batch_actions_enabled?).to
|
|
11
|
+
expect(app.batch_actions).to eq false
|
|
12
|
+
expect(ns.batch_actions).to eq false
|
|
13
|
+
expect(post_resource.batch_actions_enabled?).to eq false
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "should be settable to true" do
|
|
17
17
|
app.batch_actions = true
|
|
18
|
-
expect(app.batch_actions).to
|
|
18
|
+
expect(app.batch_actions).to eq true
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "should be an inheritable_setting" do
|
|
22
22
|
app.batch_actions = true
|
|
23
|
-
expect(ns.batch_actions).to
|
|
23
|
+
expect(ns.batch_actions).to eq true
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "should be settable at the namespace level" do
|
|
27
27
|
app.batch_actions = true
|
|
28
28
|
ns.batch_actions = false
|
|
29
29
|
|
|
30
|
-
expect(app.batch_actions).to
|
|
31
|
-
expect(ns.batch_actions).to
|
|
30
|
+
expect(app.batch_actions).to eq true
|
|
31
|
+
expect(ns.batch_actions).to eq false
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "should be settable at the resource level" do
|
|
35
|
-
expect(post_resource.batch_actions_enabled?).to
|
|
35
|
+
expect(post_resource.batch_actions_enabled?).to eq false
|
|
36
36
|
post_resource.batch_actions = true
|
|
37
|
-
expect(post_resource.batch_actions_enabled?).to
|
|
37
|
+
expect(post_resource.batch_actions_enabled?).to eq true
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "should inherit the setting on the resource from the namespace" do
|
|
41
41
|
ns.batch_actions = false
|
|
42
|
-
expect(post_resource.batch_actions_enabled?).to
|
|
42
|
+
expect(post_resource.batch_actions_enabled?).to eq false
|
|
43
43
|
expect(post_resource.batch_actions).to be_empty
|
|
44
44
|
|
|
45
45
|
post_resource.batch_actions = true
|
|
46
|
-
expect(post_resource.batch_actions_enabled?).to
|
|
46
|
+
expect(post_resource.batch_actions_enabled?).to eq true
|
|
47
47
|
expect(post_resource.batch_actions).to_not be_empty
|
|
48
48
|
end
|
|
49
49
|
|
|
@@ -51,11 +51,11 @@ describe "Batch Actions Settings" do
|
|
|
51
51
|
ns.batch_actions = true
|
|
52
52
|
|
|
53
53
|
post_resource.batch_actions = true
|
|
54
|
-
expect(post_resource.batch_actions_enabled?).to
|
|
54
|
+
expect(post_resource.batch_actions_enabled?).to eq true
|
|
55
55
|
expect(post_resource.batch_actions).to_not be_empty
|
|
56
56
|
|
|
57
57
|
post_resource.batch_actions = nil
|
|
58
|
-
expect(post_resource.batch_actions_enabled?).to
|
|
58
|
+
expect(post_resource.batch_actions_enabled?).to eq true # inherited from namespace
|
|
59
59
|
expect(post_resource.batch_actions).to_not be_empty
|
|
60
60
|
end
|
|
61
61
|
end
|
data/spec/unit/comments_spec.rb
CHANGED
|
@@ -159,13 +159,13 @@ describe "Comments" do
|
|
|
159
159
|
it "should have comments when the namespace allows comments" do
|
|
160
160
|
ns = ActiveAdmin::Namespace.new(application, :admin)
|
|
161
161
|
ns.comments = true
|
|
162
|
-
expect(ns.comments?).to
|
|
162
|
+
expect(ns.comments?).to eq true
|
|
163
163
|
end
|
|
164
164
|
|
|
165
165
|
it "should not have comments when the namespace does not allow comments" do
|
|
166
166
|
ns = ActiveAdmin::Namespace.new(application, :admin)
|
|
167
167
|
ns.comments = false
|
|
168
|
-
expect(ns.comments?).to
|
|
168
|
+
expect(ns.comments?).to eq false
|
|
169
169
|
end
|
|
170
170
|
end
|
|
171
171
|
end
|
|
@@ -174,15 +174,15 @@ describe "Comments" do
|
|
|
174
174
|
it "should add an attr_accessor :comments to ActiveAdmin::Resource" do
|
|
175
175
|
ns = ActiveAdmin::Namespace.new(application, :admin)
|
|
176
176
|
resource = ActiveAdmin::Resource.new(ns, Post)
|
|
177
|
-
expect(resource.comments).to
|
|
177
|
+
expect(resource.comments).to eq nil
|
|
178
178
|
resource.comments = true
|
|
179
|
-
expect(resource.comments).to
|
|
179
|
+
expect(resource.comments).to eq true
|
|
180
180
|
end
|
|
181
181
|
it "should disable comments if set to false" do
|
|
182
182
|
ns = ActiveAdmin::Namespace.new(application, :admin)
|
|
183
183
|
resource = ActiveAdmin::Resource.new(ns, Post)
|
|
184
184
|
resource.comments = false
|
|
185
|
-
expect(resource.comments?).to
|
|
185
|
+
expect(resource.comments?).to eq false
|
|
186
186
|
end
|
|
187
187
|
end
|
|
188
188
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Encoding: UTF-8
|
|
2
|
+
|
|
1
3
|
require 'rails_helper'
|
|
2
4
|
|
|
3
5
|
describe ActiveAdmin::CSVBuilder do
|
|
@@ -233,6 +235,63 @@ describe ActiveAdmin::CSVBuilder do
|
|
|
233
235
|
|
|
234
236
|
end
|
|
235
237
|
|
|
238
|
+
context "build csv using specified encoding and encoding_options" do
|
|
239
|
+
let(:dummy_controller) do
|
|
240
|
+
class DummyController
|
|
241
|
+
def find_collection(*)
|
|
242
|
+
collection
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def collection
|
|
246
|
+
Post
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def apply_decorator(resource)
|
|
250
|
+
resource
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def view_context
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
DummyController.new
|
|
257
|
+
end
|
|
258
|
+
let(:encoding) { Encoding::ASCII }
|
|
259
|
+
let(:opts) { {} }
|
|
260
|
+
let(:builder) do
|
|
261
|
+
ActiveAdmin::CSVBuilder.new(encoding: encoding, encoding_options: opts) do
|
|
262
|
+
column "おはようございます"
|
|
263
|
+
column "title"
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
context "Shift-JIS with options" do
|
|
268
|
+
let(:encoding) { Encoding::Shift_JIS }
|
|
269
|
+
let(:opts) { { invalid: :replace, undef: :replace, replace: "?" } }
|
|
270
|
+
|
|
271
|
+
it "encodes the CSV" do
|
|
272
|
+
receiver = []
|
|
273
|
+
builder.build dummy_controller, receiver
|
|
274
|
+
line = receiver.last
|
|
275
|
+
expect(line.encoding).to eq(encoding)
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
context "ASCII with options" do
|
|
280
|
+
let(:encoding) { Encoding::ASCII }
|
|
281
|
+
let(:opts) do
|
|
282
|
+
{ invalid: :replace, undef: :replace, replace: "__REPLACED__" }
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
it "encodes the CSV without errors" do
|
|
286
|
+
receiver = []
|
|
287
|
+
builder.build dummy_controller, receiver
|
|
288
|
+
line = receiver.last
|
|
289
|
+
expect(line.encoding).to eq(encoding)
|
|
290
|
+
expect(line).to include("__REPLACED__")
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
|
|
236
295
|
skip '#exec_columns'
|
|
237
296
|
|
|
238
297
|
skip '#build_row' do
|