diff --git a/CHANGELOG.md b/CHANGELOG.md index b001da59c43..9e5d8faeaf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Enhancements +* Rename `allow_comments` to `comments` for more consistent naming [#3695][] by [@pranas][] * Unify DSL for index `actions` and `actions dropdown: true` [#3463][] by [@timoschilling][] * Add DSL method `includes` for `ActiveRecord::Relation#includes` [#3464][] by [@timoschilling][] * BOM (byte order mark) configurable for CSV download [#3519][] by [@timoschilling][] @@ -982,6 +983,7 @@ of the highlights. 250 commits. Enough said. [#3464]: https://github.com/activeadmin/activeadmin/issues/3464 [#3486]: https://github.com/activeadmin/activeadmin/issues/3486 [#3519]: https://github.com/activeadmin/activeadmin/issues/3519 +[#3695]: https://github.com/activeadmin/activeadmin/issues/3695 [@Bishop]: https://github.com/Bishop [@BoboFraggins]: https://github.com/BoboFraggins [@DMajrekar]: https://github.com/DMajrekar @@ -1055,6 +1057,7 @@ of the highlights. 250 commits. Enough said. [@pcreux]: https://github.com/pcreux [@per_page]: https://github.com/per_page [@potatosalad]: https://github.com/potatosalad +[@pranas]: https://github.com/pranas [@psy-q]: https://github.com/psy-q [@ptn]: https://github.com/ptn [@randym]: https://github.com/randym diff --git a/docs/1-general-configuration.md b/docs/1-general-configuration.md index 8e100e00fbe..5fda24c5933 100644 --- a/docs/1-general-configuration.md +++ b/docs/1-general-configuration.md @@ -103,13 +103,13 @@ undesired. To disable comments: ```ruby # For the entire application: ActiveAdmin.setup do |config| - config.allow_comments = false + config.comments = false end # For a namespace: ActiveAdmin.setup do |config| config.namespace :admin do |admin| - admin.allow_comments = false + admin.comments = false end end diff --git a/features/comments/commenting.feature b/features/comments/commenting.feature index 8cacf3a23ca..26ff1a8f744 100644 --- a/features/comments/commenting.feature +++ b/features/comments/commenting.feature @@ -39,7 +39,7 @@ Feature: Commenting Scenario: View a resource in a namespace that doesn't have comments Given a configuration of: """ - ActiveAdmin.application.namespace(:new_namespace).allow_comments = false + ActiveAdmin.application.namespace(:new_namespace).comments = false ActiveAdmin.register Post, :namespace => :new_namespace ActiveAdmin.register AdminUser, :namespace => :new_namespace """ diff --git a/lib/active_admin/application.rb b/lib/active_admin/application.rb index 37944683711..e21e6b9b43e 100644 --- a/lib/active_admin/application.rb +++ b/lib/active_admin/application.rb @@ -109,7 +109,9 @@ def initialize # == Deprecated Settings - # (none currently) + def allow_comments= + raise "`config.allow_comments` is no longer provided in ActiveAdmin 1.x. Use `config.comments` instead." + end include AssetRegistration diff --git a/lib/active_admin/orm/active_record/comments.rb b/lib/active_admin/orm/active_record/comments.rb index a82ff15f3ae..67740893047 100644 --- a/lib/active_admin/orm/active_record/comments.rb +++ b/lib/active_admin/orm/active_record/comments.rb @@ -4,7 +4,7 @@ require 'active_admin/orm/active_record/comments/resource_helper' # Add the comments configuration -ActiveAdmin::Application.inheritable_setting :allow_comments, true +ActiveAdmin::Application.inheritable_setting :comments, true ActiveAdmin::Application.inheritable_setting :show_comments_in_menu, true ActiveAdmin::Application.inheritable_setting :comments_registration_name, 'Comment' diff --git a/lib/active_admin/orm/active_record/comments/namespace_helper.rb b/lib/active_admin/orm/active_record/comments/namespace_helper.rb index 9a32dea3b6a..3c64559bdd0 100644 --- a/lib/active_admin/orm/active_record/comments/namespace_helper.rb +++ b/lib/active_admin/orm/active_record/comments/namespace_helper.rb @@ -5,7 +5,7 @@ module NamespaceHelper # Returns true if the namespace allows comments def comments? - allow_comments == true + comments == true end end diff --git a/lib/generators/active_admin/install/templates/active_admin.rb.erb b/lib/generators/active_admin/install/templates/active_admin.rb.erb index 484911719ac..1590b7090cc 100644 --- a/lib/generators/active_admin/install/templates/active_admin.rb.erb +++ b/lib/generators/active_admin/install/templates/active_admin.rb.erb @@ -119,7 +119,7 @@ ActiveAdmin.setup do |config| # This allows your users to comment on any resource registered with Active Admin. # # You can completely disable comments: - # config.allow_comments = false + # config.comments = false # # You can disable the menu item for the comments index page: # config.show_comments_in_menu = false diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index d048927680b..9d77a86d0b9 100644 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -63,7 +63,7 @@ end it "should allow comments by default" do - expect(application.allow_comments).to eq true + expect(application.comments).to eq true end describe "authentication settings" do diff --git a/spec/unit/comments_spec.rb b/spec/unit/comments_spec.rb index 5e05e3df9a3..5097e6cf0a1 100644 --- a/spec/unit/comments_spec.rb +++ b/spec/unit/comments_spec.rb @@ -136,13 +136,13 @@ it "should have comments when the namespace allows comments" do ns = ActiveAdmin::Namespace.new(application, :admin) - ns.allow_comments = true + ns.comments = true expect(ns.comments?).to be_truthy end it "should not have comments when the namespace does not allow comments" do ns = ActiveAdmin::Namespace.new(application, :admin) - ns.allow_comments = false + ns.comments = false expect(ns.comments?).to be_falsey end end