rosa-build/spec/controllers/projects/comments_controller_for_com...

67 lines
2.7 KiB
Ruby
Raw Normal View History

2012-01-30 20:39:34 +00:00
# -*- encoding : utf-8 -*-
2012-01-13 16:00:28 +00:00
require 'spec_helper'
describe Projects::CommentsController do
2012-01-13 16:00:28 +00:00
before(:each) do
stub_symlink_methods
@project = FactoryGirl.create(:project_with_commit)
@commit = @project.repo.commits.first
2012-01-13 16:00:28 +00:00
@create_params = {:comment => {:body => 'I am a comment!'}, :owner_name => @project.owner.uname, :project_name => @project.name, :commit_id => @commit.id}
@update_params = {:comment => {:body => 'updated'}, :owner_name => @project.owner.uname, :project_name => @project.name, :commit_id => @commit.id}
2012-01-13 16:00:28 +00:00
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
@comment = FactoryGirl.create(:comment, :commentable => @commit, :project => @project)
@user = FactoryGirl.create(:user)
@own_comment = FactoryGirl.create(:comment, :commentable => @commit, :user => @user, :project => @project)
set_session_for(@user)
@path = {:owner_name => @project.owner.uname, :project_name => @project.name, :commit_id => @commit.id}
@return_path = commit_path(@project, @commit.id)
2012-01-13 16:00:28 +00:00
end
context 'for project admin user' do
before(:each) do
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
2012-01-13 16:00:28 +00:00
end
it_should_behave_like 'user with create comment ability'
it_should_behave_like 'user with update stranger comment ability'
it_should_behave_like 'user with update own comment ability'
it_should_behave_like 'user with destroy comment ability'
#it_should_behave_like 'user with destroy ability'
2012-01-13 16:00:28 +00:00
end
2012-01-14 12:16:42 +00:00
context 'for project owner user' do
before(:each) do
set_session_for(@project.owner)
2012-01-14 12:16:42 +00:00
end
it_should_behave_like 'user with create comment ability'
it_should_behave_like 'user with update stranger comment ability'
it_should_behave_like 'user with update own comment ability'
it_should_behave_like 'user with destroy comment ability'
2012-01-14 12:16:42 +00:00
end
2012-01-13 16:00:28 +00:00
context 'for project reader user' do
before(:each) do
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
2012-01-13 16:00:28 +00:00
end
it_should_behave_like 'user with create comment ability'
it_should_behave_like 'user without update stranger comment ability'
it_should_behave_like 'user with update own comment ability'
it_should_behave_like 'user without destroy comment ability'
2012-01-13 16:00:28 +00:00
end
context 'for project writer user' do
before(:each) do
@project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'writer')
2012-01-13 16:00:28 +00:00
end
it_should_behave_like 'user with create comment ability'
it_should_behave_like 'user without update stranger comment ability'
it_should_behave_like 'user with update own comment ability'
it_should_behave_like 'user without destroy comment ability'
2012-01-13 16:00:28 +00:00
end
2012-01-16 13:43:23 +00:00
end