activeadmin 1.0.0.pre1 → 1.0.0.pre2
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/.travis.yml +18 -16
- data/CHANGELOG.md +18 -1013
- data/Gemfile +18 -11
- data/LICENSE +0 -5
- data/README.md +0 -2
- data/activeadmin.gemspec +3 -1
- data/app/assets/javascripts/active_admin/application.js.coffee +8 -3
- data/app/assets/javascripts/active_admin/base.js.coffee +1 -6
- data/app/assets/javascripts/active_admin/jquery_ui.js.erb +11 -0
- data/app/assets/javascripts/active_admin/lib/flash.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +11 -3
- data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +5 -1
- data/app/assets/stylesheets/active_admin/_base.scss +1 -4
- data/app/assets/stylesheets/active_admin/_forms.scss +13 -8
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +0 -5
- data/app/assets/stylesheets/active_admin/mixins/_all.scss +0 -1
- data/app/assets/stylesheets/active_admin/mixins/_sections.scss +0 -1
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_variables.scss +1 -1
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +0 -5
- data/app/views/layouts/active_admin_logged_out.html.erb +4 -0
- data/config/locales/ar.yml +14 -2
- data/config/locales/de-CH.yml +2 -0
- data/config/locales/de.yml +15 -0
- data/config/locales/en.yml +10 -2
- data/config/locales/es.yml +26 -4
- data/config/locales/fr.yml +5 -0
- data/config/locales/id.yml +135 -0
- data/config/locales/ja.yml +21 -3
- data/config/locales/ko.yml +66 -36
- data/config/locales/nl.yml +14 -1
- data/config/locales/pt-BR.yml +11 -0
- data/config/locales/ru.yml +15 -1
- data/config/locales/sv-SE.yml +45 -5
- data/config/locales/uk.yml +16 -4
- data/config/locales/zh-CN.yml +5 -0
- data/config/locales/zh-TW.yml +32 -1
- data/docs/0-installation.md +7 -1
- data/docs/1-general-configuration.md +9 -0
- data/docs/10-custom-pages.md +10 -0
- data/docs/12-arbre-components.md +1 -1
- data/docs/14-gotchas.md +2 -2
- data/docs/2-resource-customization.md +5 -3
- data/docs/3-index-pages.md +7 -0
- data/docs/3-index-pages/index-as-table.md +4 -0
- data/docs/6-show-pages.md +1 -1
- data/docs/7-sidebars.md +8 -0
- data/features/index/batch_actions.feature +21 -2
- data/features/index/pagination.feature +16 -12
- data/features/meta_tags.feature +21 -0
- data/features/registering_assets.feature +1 -2
- data/features/show/columns.feature +40 -0
- data/features/show/default_content.feature +2 -1
- data/features/step_definitions/asset_steps.rb +3 -3
- data/features/step_definitions/batch_action_steps.rb +11 -2
- data/features/step_definitions/column_steps.rb +8 -0
- data/features/step_definitions/configuration_steps.rb +2 -2
- data/features/step_definitions/factory_steps.rb +3 -2
- data/features/step_definitions/meta_tag_steps.rb +3 -0
- data/features/step_definitions/pagination_steps.rb +8 -0
- data/features/step_definitions/table_steps.rb +2 -1
- data/lib/active_admin.rb +3 -3
- data/lib/active_admin/application.rb +66 -16
- data/lib/active_admin/batch_actions.rb +0 -1
- data/lib/active_admin/batch_actions/controller.rb +2 -2
- data/lib/active_admin/batch_actions/resource_extension.rb +3 -1
- data/lib/active_admin/callbacks.rb +1 -1
- data/lib/active_admin/csv_builder.rb +2 -2
- data/lib/active_admin/dependency.rb +18 -16
- data/lib/active_admin/devise.rb +1 -1
- data/lib/active_admin/dsl.rb +1 -1
- data/lib/active_admin/event.rb +8 -17
- data/lib/active_admin/filters/active.rb +29 -0
- data/lib/active_admin/filters/forms.rb +6 -1
- data/lib/active_admin/filters/humanized.rb +68 -0
- data/lib/active_admin/filters/resource_extension.rb +48 -1
- data/lib/active_admin/form_builder.rb +4 -4
- data/lib/active_admin/generators/boilerplate.rb +37 -0
- data/lib/active_admin/helpers/routes/url_helpers.rb +1 -1
- data/lib/active_admin/inputs.rb +1 -0
- data/lib/active_admin/inputs/filters/date_picker_input.rb +13 -0
- data/lib/active_admin/inputs/filters/date_range_input.rb +1 -1
- data/lib/active_admin/menu.rb +1 -0
- data/lib/active_admin/menu_item.rb +1 -1
- data/lib/active_admin/namespace.rb +5 -5
- data/lib/active_admin/orm/active_record/comments.rb +10 -1
- data/lib/active_admin/orm/active_record/comments/comment.rb +1 -1
- data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +11 -0
- data/lib/active_admin/resource.rb +9 -3
- data/lib/active_admin/resource/action_items.rb +13 -3
- data/lib/active_admin/resource/belongs_to.rb +6 -2
- data/lib/active_admin/resource/pagination.rb +4 -0
- data/lib/active_admin/resource_collection.rb +3 -1
- data/lib/active_admin/resource_controller/data_access.rb +6 -11
- data/lib/active_admin/resource_controller/decorators.rb +1 -1
- data/lib/active_admin/resource_dsl.rb +8 -2
- data/lib/active_admin/sidebar_section.rb +4 -12
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +1 -2
- data/lib/active_admin/view_helpers.rb +0 -1
- data/lib/active_admin/view_helpers/display_helper.rb +3 -4
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +3 -3
- data/lib/active_admin/views/components/active_admin_form.rb +3 -3
- data/lib/active_admin/views/components/columns.rb +9 -4
- data/lib/active_admin/views/components/dropdown_menu.rb +0 -2
- data/lib/active_admin/views/components/paginated_collection.rb +35 -13
- data/lib/active_admin/views/components/panel.rb +1 -3
- data/lib/active_admin/views/components/sidebar_section.rb +6 -1
- data/lib/active_admin/views/components/status_tag.rb +3 -2
- data/lib/active_admin/views/components/table_for.rb +2 -1
- data/lib/active_admin/views/index_as_table.rb +2 -2
- data/lib/active_admin/views/pages/base.rb +4 -0
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/generators/active_admin/assets/assets_generator.rb +1 -1
- data/lib/generators/active_admin/assets/templates/{active_admin.css.scss → active_admin.scss} +0 -0
- data/lib/generators/active_admin/devise/devise_generator.rb +7 -19
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +29 -0
- data/lib/generators/active_admin/page/templates/page.rb +1 -1
- data/lib/generators/active_admin/resource/resource_generator.rb +6 -0
- data/lib/generators/active_admin/resource/templates/admin.rb +34 -13
- data/spec/rails_helper.rb +6 -2
- data/spec/requests/memory_spec.rb +1 -3
- data/spec/support/active_admin_request_helpers.rb +27 -0
- data/spec/support/detect_rails_version.rb +1 -1
- data/spec/support/rails_template.rb +7 -0
- data/spec/unit/application_spec.rb +29 -4
- data/spec/unit/batch_actions/resource_spec.rb +5 -0
- data/spec/unit/belongs_to_spec.rb +14 -0
- data/spec/unit/comments_spec.rb +24 -2
- data/spec/unit/controller_filters_spec.rb +25 -28
- data/spec/unit/dsl_spec.rb +1 -1
- data/spec/unit/filters/humanized_spec.rb +56 -0
- data/spec/unit/filters/resource_spec.rb +1 -1
- data/spec/unit/form_builder_spec.rb +71 -11
- data/spec/unit/generators/install_spec.rb +3 -2
- data/spec/unit/pretty_format_spec.rb +15 -1
- data/spec/unit/resource_collection_spec.rb +17 -0
- data/spec/unit/resource_controller_spec.rb +2 -2
- data/spec/unit/resource_registration_spec.rb +3 -3
- data/spec/unit/resource_spec.rb +53 -2
- data/spec/unit/view_factory_spec.rb +0 -2
- data/spec/unit/view_helpers/display_name_spec.rb +6 -4
- data/spec/unit/views/components/{batch_action_popover_spec.rb → batch_action_selector_spec.rb} +9 -13
- data/spec/unit/views/components/columns_spec.rb +17 -0
- data/spec/unit/views/components/paginated_collection_spec.rb +16 -2
- data/spec/unit/views/components/panel_spec.rb +1 -5
- data/spec/unit/views/components/sidebar_section_spec.rb +21 -0
- data/spec/unit/views/components/status_tag_spec.rb +15 -1
- data/spec/unit/views/components/table_for_spec.rb +45 -0
- data/tasks/parallel_tests.rake +1 -1
- data/tasks/test.rake +4 -4
- metadata +29 -30
- data/app/assets/javascripts/active_admin/lib/popover.js.coffee +0 -68
- data/app/assets/stylesheets/active_admin/components/_popovers.scss +0 -122
- data/app/assets/stylesheets/active_admin/mixins/_icons.scss +0 -20
- data/lib/active_admin/batch_actions/views/batch_action_popover.rb +0 -28
- data/lib/active_admin/iconic.rb +0 -53
- data/lib/active_admin/iconic/icons.rb +0 -142
- data/lib/active_admin/view_helpers/icon_helper.rb +0 -12
- data/lib/active_admin/views/components/action_list_popover.rb +0 -29
- data/lib/active_admin/views/components/popover.rb +0 -27
- data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +0 -82
- data/spec/support/integration_example_group.rb +0 -31
- data/spec/unit/event_spec.rb +0 -47
- data/spec/unit/views/components/action_list_popover_spec.rb +0 -40
- data/spec/unit/views/components/popover_spec.rb +0 -33
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe "Memory Leak", :
|
4
|
-
|
3
|
+
describe "Memory Leak", type: :request, if: RUBY_ENGINE == 'ruby' do
|
5
4
|
def count_instances_of(klass)
|
6
5
|
ObjectSpace.each_object(klass) { }
|
7
6
|
end
|
@@ -19,5 +18,4 @@ describe "Memory Leak", :type => :request do
|
|
19
18
|
expect(count_instances_of klass).to be <= count
|
20
19
|
end
|
21
20
|
end
|
22
|
-
|
23
21
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "action_dispatch"
|
2
|
+
require "capybara/rails"
|
3
|
+
require "capybara/dsl"
|
4
|
+
|
5
|
+
module ActiveAdminRequestHelpers
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
include ActionDispatch::Integration::Runner
|
9
|
+
include RSpec::Rails::TestUnitAssertionAdapter
|
10
|
+
include ActionDispatch::Assertions
|
11
|
+
include Capybara::DSL
|
12
|
+
include RSpec::Matchers
|
13
|
+
|
14
|
+
def app
|
15
|
+
::Rails.application
|
16
|
+
end
|
17
|
+
|
18
|
+
def last_response
|
19
|
+
page
|
20
|
+
end
|
21
|
+
|
22
|
+
included do
|
23
|
+
before do
|
24
|
+
@router = ::Rails.application.routes
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -10,7 +10,7 @@ unless defined? TRAVIS_CONFIG
|
|
10
10
|
TRAVIS_RAILS_VERSIONS = TRAVIS_CONFIG['env']['matrix'].grep(/RAILS=(.*)/){ $1 }
|
11
11
|
end
|
12
12
|
|
13
|
-
DEFAULT_RAILS_VERSION ||= TRAVIS_RAILS_VERSIONS.
|
13
|
+
DEFAULT_RAILS_VERSION ||= TRAVIS_RAILS_VERSIONS.last
|
14
14
|
|
15
15
|
def detect_rails_version
|
16
16
|
version = version_from_file || ENV['RAILS'] || DEFAULT_RAILS_VERSION
|
@@ -38,14 +38,21 @@ inject_into_file 'app/models/blog/post.rb', %q{
|
|
38
38
|
}, after: 'class Blog::Post < ActiveRecord::Base'
|
39
39
|
|
40
40
|
|
41
|
+
generate :model, "profile user_id:integer bio:text"
|
41
42
|
generate :model, "user type:string first_name:string last_name:string username:string age:integer"
|
42
43
|
inject_into_file 'app/models/user.rb', %q{
|
43
44
|
has_many :posts, foreign_key: 'author_id'
|
45
|
+
has_one :profile
|
46
|
+
accepts_nested_attributes_for :profile, allow_destroy: true
|
44
47
|
def display_name
|
45
48
|
"#{first_name} #{last_name}"
|
46
49
|
end
|
47
50
|
}, after: 'class User < ActiveRecord::Base'
|
48
51
|
|
52
|
+
inject_into_file 'app/models/profile.rb', %q{
|
53
|
+
belongs_to :user
|
54
|
+
}, after: 'class Profile < ActiveRecord::Base'
|
55
|
+
|
49
56
|
generate :model, 'publisher --migration=false --parent=User'
|
50
57
|
generate :model, 'category name:string description:text'
|
51
58
|
inject_into_file 'app/models/category.rb', %q{
|
@@ -18,10 +18,6 @@ describe ActiveAdmin::Application do
|
|
18
18
|
expect(ActiveSupport::Dependencies.autoload_paths).to_not include(File.join(Rails.root, "app/admin"))
|
19
19
|
end
|
20
20
|
|
21
|
-
it "should add app/admin to the Engine's watchable directories (loaded after the app itself)" do
|
22
|
-
expect(ActiveAdmin::Engine.config.watchable_dirs).to have_key File.join(Rails.root, "app/admin")
|
23
|
-
end
|
24
|
-
|
25
21
|
it "should store the site's title" do
|
26
22
|
expect(application.site_title).to eq ""
|
27
23
|
end
|
@@ -53,11 +49,40 @@ describe ActiveAdmin::Application do
|
|
53
49
|
expect(application.favicon).to eq false
|
54
50
|
end
|
55
51
|
|
52
|
+
it "should return default localize format" do
|
53
|
+
expect(application.localize_format).to eq :long
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should set localize format" do
|
57
|
+
application.localize_format = :default
|
58
|
+
expect(application.localize_format).to eq :default
|
59
|
+
end
|
60
|
+
|
56
61
|
it "should set the site's favicon" do
|
57
62
|
application.favicon = "/a/favicon.ico"
|
58
63
|
expect(application.favicon).to eq "/a/favicon.ico"
|
59
64
|
end
|
60
65
|
|
66
|
+
it "should store meta tags" do
|
67
|
+
expect(application.meta_tags).to eq({})
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should set meta tags" do
|
71
|
+
application.meta_tags = { author: "My Company" }
|
72
|
+
expect(application.meta_tags).to eq(author: "My Company")
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should contains robots meta tags by default" do
|
76
|
+
result = application.meta_tags_for_logged_out_pages
|
77
|
+
expect(result).to eq(robots: "noindex, nofollow")
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should set meta tags for logged out pages" do
|
81
|
+
value = { author: "My Company" }
|
82
|
+
application.meta_tags_for_logged_out_pages = value
|
83
|
+
expect(application.meta_tags_for_logged_out_pages).to eq value
|
84
|
+
end
|
85
|
+
|
61
86
|
it "should have a view factory" do
|
62
87
|
expect(application.view_factory).to be_an_instance_of(ActiveAdmin::ViewFactory)
|
63
88
|
end
|
@@ -58,6 +58,11 @@ describe ActiveAdmin::BatchActions::ResourceExtension do
|
|
58
58
|
expect(resource.batch_action_path).to eq "/admin/posts/batch_action"
|
59
59
|
end
|
60
60
|
|
61
|
+
it "includes :scope and :q params" do
|
62
|
+
params = { q: { name_equals: "Any" }, scope: :all }
|
63
|
+
batch_action_path = "/admin/posts/batch_action?q%5Bname_equals%5D=Any&scope=all"
|
64
|
+
expect(resource.batch_action_path(params)).to eq(batch_action_path)
|
65
|
+
end
|
61
66
|
end
|
62
67
|
|
63
68
|
describe "#display_if_block" do
|
@@ -26,6 +26,20 @@ describe ActiveAdmin::Resource::BelongsTo do
|
|
26
26
|
}.to raise_error(ActiveAdmin::Resource::BelongsTo::TargetNotFound)
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
context "when the resource is on a namespace" do
|
31
|
+
let(:blog_post_config){ ActiveAdmin.register Blog::Post do; end }
|
32
|
+
let(:belongs_to) { ActiveAdmin::Resource::BelongsTo.new blog_post_config, :blog_author, class_name: "Blog::Author" }
|
33
|
+
before do
|
34
|
+
class Blog::Author
|
35
|
+
include ActiveModel::Naming
|
36
|
+
end
|
37
|
+
@blog_author_config = ActiveAdmin.register Blog::Author do; end
|
38
|
+
end
|
39
|
+
it "should return the target resource" do
|
40
|
+
expect(belongs_to.target).to eq @blog_author_config
|
41
|
+
end
|
42
|
+
end
|
29
43
|
end
|
30
44
|
|
31
45
|
it "should be optional" do
|
data/spec/unit/comments_spec.rb
CHANGED
@@ -29,7 +29,9 @@ describe "Comments" do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should not return a comment for the same resource in a different namespace" do
|
32
|
+
ActiveAdmin.application.namespaces[:public] = ActiveAdmin.application.namespaces[:admin]
|
32
33
|
expect(ActiveAdmin::Comment.find_for_resource_in_namespace(post, 'public')).to eq []
|
34
|
+
ActiveAdmin.application.namespaces.instance_variable_get(:@namespaces).delete(:public)
|
33
35
|
end
|
34
36
|
|
35
37
|
it "should not return a comment for a different resource" do
|
@@ -39,8 +41,8 @@ describe "Comments" do
|
|
39
41
|
|
40
42
|
it "should return the most recent comment first" do
|
41
43
|
ActiveAdmin::Comment.class_eval { attr_accessible :created_at } if Rails::VERSION::MAJOR == 3
|
42
|
-
another_comment = ActiveAdmin::Comment.create! resource: post,
|
43
|
-
body: "Another Comment",
|
44
|
+
another_comment = ActiveAdmin::Comment.create! resource: post,
|
45
|
+
body: "Another Comment",
|
44
46
|
namespace: namespace_name,
|
45
47
|
created_at: @comment.created_at + 20.minutes
|
46
48
|
|
@@ -55,6 +57,26 @@ describe "Comments" do
|
|
55
57
|
expect(comments.second).to eq(yet_another_comment)
|
56
58
|
expect(comments.last).to eq(another_comment)
|
57
59
|
end
|
60
|
+
|
61
|
+
it "should return the correctly ordered comments" do
|
62
|
+
ActiveAdmin::Application.inheritable_setting(
|
63
|
+
:comments_order, "created_at DESC"
|
64
|
+
)
|
65
|
+
|
66
|
+
another_comment = ActiveAdmin::Comment.create!(
|
67
|
+
resource: post,
|
68
|
+
body: "Another Comment",
|
69
|
+
namespace: namespace_name,
|
70
|
+
created_at: @comment.created_at + 20.minutes
|
71
|
+
)
|
72
|
+
|
73
|
+
comments = ActiveAdmin::Comment.find_for_resource_in_namespace(
|
74
|
+
post, namespace_name
|
75
|
+
)
|
76
|
+
expect(comments.size).to eq 2
|
77
|
+
expect(comments.first).to eq(another_comment)
|
78
|
+
expect(comments.last).to eq(@comment)
|
79
|
+
end
|
58
80
|
end
|
59
81
|
|
60
82
|
describe ".resource_id_cast" do
|
@@ -12,33 +12,30 @@ describe ActiveAdmin::Application do
|
|
12
12
|
]
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
it 'skip_filter' do
|
41
|
-
controllers.each{ |c| expect(c).to receive(:skip_filter).and_return(true) }
|
42
|
-
application.skip_filter :my_filter, only: :show
|
15
|
+
expected_actions = (
|
16
|
+
prefixes = %w(skip append prepend) << nil
|
17
|
+
positions = %w(before around after)
|
18
|
+
suffixes = %w(filter)
|
19
|
+
base = %w(skip_filter)
|
20
|
+
if Rails::VERSION::MAJOR >= 4
|
21
|
+
suffixes += %w(action)
|
22
|
+
base += %w(skip_action_callback)
|
23
|
+
end
|
24
|
+
|
25
|
+
prefixes.each_with_object(base) do |prefix, stack|
|
26
|
+
positions.each do |position|
|
27
|
+
suffixes.each do |suffix|
|
28
|
+
stack << [prefix, position, suffix].compact.join("_").to_sym
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
)
|
33
|
+
|
34
|
+
expected_actions.each do |action|
|
35
|
+
it action do
|
36
|
+
args = [:my_filter, { only: :show }]
|
37
|
+
controllers.each { |c| expect(c).to receive(action).with(args) }
|
38
|
+
application.public_send action, args
|
39
|
+
end
|
43
40
|
end
|
44
41
|
end
|
data/spec/unit/dsl_spec.rb
CHANGED
@@ -97,7 +97,7 @@ describe ActiveAdmin::DSL do
|
|
97
97
|
dsl.run_registration_block do
|
98
98
|
sidebar :help
|
99
99
|
end
|
100
|
-
expect(dsl.config.sidebar_sections.map(&:name)).to match_array
|
100
|
+
expect(dsl.config.sidebar_sections.map(&:name)).to match_array %w{filters search_status email help}
|
101
101
|
end
|
102
102
|
|
103
103
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe ActiveAdmin::Filters::Humanized do
|
4
|
+
describe '#value' do
|
5
|
+
it 'should equal query string parameter if not an Array' do
|
6
|
+
param = ['category_id_eq', '1']
|
7
|
+
subject = ActiveAdmin::Filters::Humanized.new(param)
|
8
|
+
expect(subject.value).to eq('1')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should equal query string parameters separated by commas if an Array' do
|
12
|
+
param = ['category_id_eq', ['1', '2']]
|
13
|
+
subject = ActiveAdmin::Filters::Humanized.new(param)
|
14
|
+
expect(subject.value).to eq("1, 2")
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should remove nil values before joining equal query string parameters separated by commas if an Array' do
|
18
|
+
param = ['category_id_eq', ['1', nil, '2']]
|
19
|
+
subject = ActiveAdmin::Filters::Humanized.new(param)
|
20
|
+
expect(subject.value).to eq("1, 2")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#body' do
|
25
|
+
context 'when Ransack predicate' do
|
26
|
+
it 'parses language from Ransack' do
|
27
|
+
param = ['category_id_eq', '1']
|
28
|
+
subject = ActiveAdmin::Filters::Humanized.new(param)
|
29
|
+
expect(subject.body).to eq('Category ID equals')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'handles strings with embedded predicates' do
|
33
|
+
param = ['requires_approval_eq', '1']
|
34
|
+
humanizer = ActiveAdmin::Filters::Humanized.new(param)
|
35
|
+
expect(humanizer.value).to eq('1')
|
36
|
+
expect(humanizer.body).to eq('Requires Approval equals')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when ActiveAdmin predicate' do
|
41
|
+
it 'parses language from ActiveAdmin' do
|
42
|
+
param = ['name_starts_with', 'test']
|
43
|
+
humanizer = ActiveAdmin::Filters::Humanized.new(param)
|
44
|
+
expect(humanizer.body).to eq('Name starts with')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when unknown predicate' do
|
49
|
+
it 'uses raw predicate string' do
|
50
|
+
param = ['name_predicate_does_not_exist', 'test']
|
51
|
+
humanizer = ActiveAdmin::Filters::Humanized.new(param)
|
52
|
+
expect(humanizer.body).to eq("Name Predicate Does Not Exist")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -115,7 +115,7 @@ describe ActiveAdmin::Filters::ResourceExtension do
|
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should add a sidebar section for the filters" do
|
118
|
-
expect(resource.sidebar_sections.first.name).to eq
|
118
|
+
expect(resource.sidebar_sections.first.name).to eq "filters"
|
119
119
|
end
|
120
120
|
|
121
121
|
end
|
@@ -27,6 +27,10 @@ describe ActiveAdmin::FormBuilder do
|
|
27
27
|
"A Helper Method"
|
28
28
|
end
|
29
29
|
|
30
|
+
def view.fa_icon(*args)
|
31
|
+
args.inspect
|
32
|
+
end
|
33
|
+
|
30
34
|
view
|
31
35
|
end
|
32
36
|
|
@@ -273,21 +277,44 @@ describe ActiveAdmin::FormBuilder do
|
|
273
277
|
|
274
278
|
end
|
275
279
|
|
276
|
-
context "with
|
280
|
+
context "with a has_one relation on an author's profile" do
|
277
281
|
let :body do
|
282
|
+
author = user()
|
278
283
|
build_form do |f|
|
279
284
|
f.inputs do
|
280
285
|
f.input :title
|
281
286
|
f.input :body
|
282
287
|
end
|
283
288
|
f.form_builder.instance_eval do
|
284
|
-
@object.author =
|
289
|
+
@object.author = author
|
285
290
|
end
|
286
291
|
f.inputs name: 'Author', for: :author do |author|
|
287
|
-
author.
|
292
|
+
author.has_many :profile, allow_destroy: true do |profile|
|
293
|
+
profile.input :bio
|
294
|
+
end
|
288
295
|
end
|
289
296
|
end
|
290
297
|
end
|
298
|
+
|
299
|
+
it "should see the button to add profile" do
|
300
|
+
def user
|
301
|
+
User.new
|
302
|
+
end
|
303
|
+
expect(body).to have_selector("a[contains(data-html,'post[author_attributes][profile_attributes][bio]')]")
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should see the profile fields for an existing profile" do
|
307
|
+
def user
|
308
|
+
u = User.new
|
309
|
+
u.profile = Profile.new
|
310
|
+
u
|
311
|
+
end
|
312
|
+
expect(body).to have_selector("[id='post_author_attributes_profile_attributes_bio']", count: 1)
|
313
|
+
expect(body).to have_selector("textarea[name='post[author_attributes][profile_attributes][bio]']")
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
shared_examples :inputs_with_for_expectation do
|
291
318
|
it "should generate a nested text input once" do
|
292
319
|
expect(body).to have_selector("[id=post_author_attributes_first_name_input]", count: 1)
|
293
320
|
expect(body).to have_selector("[id=post_author_attributes_last_name_input]", count: 1)
|
@@ -298,7 +325,26 @@ describe ActiveAdmin::FormBuilder do
|
|
298
325
|
end
|
299
326
|
end
|
300
327
|
|
301
|
-
context "with
|
328
|
+
context "with inputs 'for'" do
|
329
|
+
let :body do
|
330
|
+
build_form do |f|
|
331
|
+
f.inputs do
|
332
|
+
f.input :title
|
333
|
+
f.input :body
|
334
|
+
end
|
335
|
+
f.form_builder.instance_eval do
|
336
|
+
@object.author = User.new
|
337
|
+
end
|
338
|
+
f.inputs name: 'Author', for: :author do |author|
|
339
|
+
author.inputs :first_name, :last_name
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
include_examples :inputs_with_for_expectation
|
345
|
+
end
|
346
|
+
|
347
|
+
context "with two input fields 'for' at the end of block" do
|
302
348
|
let :body do
|
303
349
|
build_form do |f|
|
304
350
|
f.inputs do
|
@@ -314,14 +360,28 @@ describe ActiveAdmin::FormBuilder do
|
|
314
360
|
end
|
315
361
|
end
|
316
362
|
end
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
363
|
+
|
364
|
+
include_examples :inputs_with_for_expectation
|
365
|
+
end
|
366
|
+
|
367
|
+
context "with two input fields 'for' at the beginning of block" do
|
368
|
+
let :body do
|
369
|
+
build_form do |f|
|
370
|
+
f.form_builder.instance_eval do
|
371
|
+
@object.author = User.new
|
372
|
+
end
|
373
|
+
f.inputs name: 'Author', for: :author do |author|
|
374
|
+
author.input :first_name
|
375
|
+
author.input :last_name
|
376
|
+
end
|
377
|
+
f.inputs do
|
378
|
+
f.input :title
|
379
|
+
f.input :body
|
380
|
+
end
|
381
|
+
end
|
324
382
|
end
|
383
|
+
|
384
|
+
include_examples :inputs_with_for_expectation
|
325
385
|
end
|
326
386
|
|
327
387
|
context "with wrapper html" do
|