diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 54eb899f5..79ba1e827 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -75,8 +75,8 @@ describe CommentsController do stub_rsync_methods @project = Factory(:project) - @issue = Factory(:issue, :project_id => @project.id) - @comment = Factory(:comment, :commentable => @issue) + @issue = Factory(:issue, :project_id => @project.id, :creator => Factory(:user)) + @comment = Factory(:comment, :commentable => @issue, :project_id => @project.id) @create_params = {:comment => {:body => 'I am a comment!'}, :project_id => @project.id, :issue_id => @issue.serial_id} @update_params = {:comment => {:body => 'updated'}, :project_id => @project.id, :issue_id => @issue.serial_id} @@ -92,7 +92,7 @@ describe CommentsController do set_session_for(@user) @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') - @own_comment = Factory(:comment, :commentable => @issue, :user => @user) + @own_comment = Factory(:comment, :commentable => @issue, :user => @user, :project_id => @project.id) end it_should_behave_like 'user with create comment rights' @@ -108,7 +108,7 @@ describe CommentsController do @project.update_attribute(:owner, @user) @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') - @own_comment = Factory(:comment, :commentable => @issue, :user => @user) + @own_comment = Factory(:comment, :commentable => @issue, :user => @user, :project_id => @project.id) end it_should_behave_like 'user with create comment rights' @@ -123,7 +123,7 @@ describe CommentsController do set_session_for(@user) @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader') - @own_comment = Factory(:comment, :commentable => @issue, :user => @user) + @own_comment = Factory(:comment, :commentable => @issue, :user => @user, :project_id => @project.id) end it_should_behave_like 'user with create comment rights' @@ -138,7 +138,7 @@ describe CommentsController do set_session_for(@user) @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer') - @own_comment = Factory(:comment, :commentable => @issue, :user => @user) + @own_comment = Factory(:comment, :commentable => @issue, :user => @user, :project_id => @project.id) end it_should_behave_like 'user with create comment rights' diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index d692beb19..97fe4425d 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -6,10 +6,10 @@ def set_commentable_data @ability = Ability.new(@user) @project = Factory(:project) - @issue = Factory(:issue, :project_id => @project.id) + @issue = Factory(:issue, :project_id => @project.id, :creator => @user) - @comment = Factory(:comment, :commentable => @issue, :user => @user) - @stranger_comment = Factory(:comment, :commentable => @issue, :user => @stranger) + @comment = Factory(:comment, :commentable => @issue, :user => @user, :project => @project) + @stranger_comment = Factory(:comment, :commentable => @issue, :user => @stranger, :project => @project) any_instance_of(Project, :versions => ['v1.0', 'v2.0']) end @@ -25,7 +25,7 @@ describe Comment do end it 'should create comment' do - @ability.should be_able_to(:create, Comment.new(:commentable => @issue, :user => @user)) + @ability.should be_able_to(:create, @comment) end pending "sends an e-mail" do @@ -60,7 +60,8 @@ describe Comment do end it 'should create comment' do - @ability.should be_able_to(:create, Comment.new(:commentable => @issue, :user => @user)) + @comment.user = @user + @ability.should be_able_to(:create, @comment) end it 'should update comment' do @@ -88,7 +89,7 @@ describe Comment do end it 'should create comment' do - @ability.should be_able_to(:create, Comment.new(:commentable => @issue, :user => @user)) + @ability.should be_able_to(:create, @comment) end it 'should update comment' do @@ -113,7 +114,7 @@ describe Comment do end it 'should create comment' do - @ability.should be_able_to(:create, Comment.new(:commentable => @issue, :user => @user)) + @ability.should be_able_to(:create, @comment) end it 'should update comment' do