Skip to content

Commit

Permalink
Turn on parameter whitelisting and get specs to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
jgadbois committed Apr 24, 2012
1 parent e482122 commit 6f2e566
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/models/forem/forum.rb
Expand Up @@ -11,6 +11,8 @@ class Forum < ActiveRecord::Base

validates :category, :title, :description, :presence => true

attr_accessible :category_id, :title, :description, :moderator_ids

def last_post_for(forem_user)
forem_user && forem_user.forem_admin? || moderator?(forem_user) ? posts.last : last_visible_post
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/forem/group.rb
Expand Up @@ -5,6 +5,8 @@ class Group < ActiveRecord::Base
has_many :memberships
has_many :members, :through => :memberships, :class_name => Forem.user_class.to_s

attr_accessible :name

def to_s
name
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/forem/membership.rb
Expand Up @@ -2,5 +2,7 @@ module Forem
class Membership < ActiveRecord::Base
belongs_to :group
belongs_to :member, :class_name => Forem.user_class.to_s

attr_accessible :member_id, :group_id
end
end
2 changes: 2 additions & 0 deletions app/models/forem/moderator_group.rb
Expand Up @@ -2,5 +2,7 @@ module Forem
class ModeratorGroup < ActiveRecord::Base
belongs_to :forum, :inverse_of => :moderator_groups
belongs_to :group

attr_accessible :group_id
end
end
2 changes: 2 additions & 0 deletions app/models/forem/post.rb
Expand Up @@ -15,6 +15,8 @@ class Post < ActiveRecord::Base
# Used in the moderation tools partial
attr_accessor :moderation_option

attr_accessible :text, :reply_to_id

belongs_to :topic
belongs_to :user, :class_name => Forem.user_class.to_s
belongs_to :reply_to, :class_name => "Post"
Expand Down
2 changes: 2 additions & 0 deletions app/models/forem/subscription.rb
Expand Up @@ -5,6 +5,8 @@ class Subscription < ActiveRecord::Base

validates :subscriber_id, :presence => true

attr_accessible :subscriber_id

def send_notification(post_id)
SubscriptionMailer.topic_reply(post_id, self.subscriber.id).deliver
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/forem/view.rb
Expand Up @@ -8,6 +8,8 @@ class View < ActiveRecord::Base
validates :viewable_id, :presence => true
validates :viewable_type, :presence => true

attr_accessible :user, :current_viewed_at, :count

def viewed_at
updated_at
end
Expand Down
6 changes: 5 additions & 1 deletion db/seeds.rb
Expand Up @@ -4,9 +4,13 @@
:title => "Default",
:description => "Default forem created by install")

post = Forem::Post.find_or_initialize_by_text("Hello World")
post.user = user

topic = Forem::Topic.find_or_initialize_by_subject("Welcome to Forem")
topic.forum = forum
topic.user = user
topic.posts_attributes = [{:text => "Hello World", :user_id => user.id}]
topic.posts = [ post ]

topic.save!
end
5 changes: 5 additions & 0 deletions spec/lib/generators/forem/dummy/dummy_generator.rb
Expand Up @@ -56,6 +56,11 @@ def test_dummy_config
inject_into_file "#{dummy_path}/config/application.rb",
"\nrequire 'kaminari'\n",
:before => "module Dummy"

inject_into_file "#{dummy_path}/config/application.rb",
"\n config.active_record.whitelist_attributes = true\n",
:before => "end\nend\n",
:verbose => false
end

protected
Expand Down
2 changes: 1 addition & 1 deletion spec/support/factories/topics.rb
Expand Up @@ -3,7 +3,7 @@
t.subject "FIRST TOPIC"
t.forum {|f| f.association(:forum) }
t.user {|u| u.association(:user) }
t.posts_attributes { [Factory.attributes_for(:post)] }
t.posts_attributes { [:text => "This is a brand new post"] }

trait :approved do
state 'approved'
Expand Down

0 comments on commit 6f2e566

Please sign in to comment.