Skip to content

Commit

Permalink
Change config.allow_comments to config.comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pranas committed Dec 16, 2014
1 parent e4f8dbb commit 7eac9cd
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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][]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/1-general-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion features/comments/commenting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
4 changes: 3 additions & 1 deletion lib/active_admin/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/active_admin/orm/active_record/comments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module NamespaceHelper

# Returns true if the namespace allows comments
def comments?
allow_comments == true
comments == true
end

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/comments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7eac9cd

Please sign in to comment.