#369: updated specs

This commit is contained in:
Vokhmin Alexey V 2014-11-25 00:16:51 +03:00
parent e01a63a163
commit 4f3c9a8f3f
3 changed files with 7 additions and 51 deletions

View File

@ -128,26 +128,11 @@ shared_examples_for 'platform user with member rights' do
end
end
context 'platform user with remove_member rights' do
let(:member) { FactoryGirl.create(:user) }
before do
@platform.add_member(member)
delete :remove_member, {member_id: member.id, id: @platform.id}
end
it 'should be able to perform remove_member action' do
response.should redirect_to(members_platform_path(@platform))
end
it 'ensures that member has been removed from platform' do
@platform.members.should_not include(member)
end
end
context 'platform user with remove_members rights' do
let(:member) { FactoryGirl.create(:user) }
before do
@platform.add_member(member)
post :remove_members, {user_remove: {member.id => [1]}, id: @platform.id}
post :remove_members, members: [member.id], id: @platform.id
end
it 'should be able to perform remove_members action' do
@ -176,26 +161,11 @@ shared_examples_for 'platform user without member rights' do |guest = false|
end
end
context 'platform user without remove_member rights' do
let(:member) { FactoryGirl.create(:user) }
before do
@platform.add_member(member)
delete :remove_member, {member_id: member.id, id: @platform.id}
end
it 'should not be able to perform remove_member action' do
response.should redirect_to(guest ? new_user_session_path : forbidden_path)
end
it 'ensures that member has not been removed from platform' do
@platform.members.should include(member)
end
end
context 'platform user without remove_members rights' do
let(:member) { FactoryGirl.create(:user) }
before do
@platform.add_member(member)
post :remove_members, {user_remove: {member.id => [1]}, id: @platform.id}
post :remove_members, members: [member.id], id: @platform.id
end
it 'should not be able to perform remove_members action' do

View File

@ -30,8 +30,8 @@ describe Platforms::ProductsController do
@product = FactoryGirl.create(:product, platform: @platform)
@project = FactoryGirl.create(:project)
params = {platform_id: @platform, src_project: @project.name_with_owner}
@create_params = params.merge({product: {name: 'pro', time_living: 150}})
params = {platform_id: @platform}
@create_params = params.merge({product: {name: 'pro', time_living: 150, project_id: @project.id}})
@update_params = params.merge({product: {name: 'pro2'}})
@user = FactoryGirl.create(:user)

View File

@ -95,19 +95,12 @@ shared_examples_for 'registered user or guest' do
@repository.members.should_not include(@another_user)
end
it 'should not be able to remove member from repository' do
create_relation(@repository, @another_user, 'admin')
delete :remove_member, id: @repository, platform_id: @platform, member_id: @another_user.id
response.should redirect_to(redirect_path)
@repository.members.should include(@another_user)
end
it 'should not be able to remove members from repository' do
another_user2 = FactoryGirl.create(:user)
create_relation(@repository, @another_user, 'admin')
create_relation(@repository, another_user2, 'admin')
post :remove_members, id: @repository, platform_id: @platform,
user_remove: {@another_user.id => [1], another_user2.id => [1]}
members: [@another_user.id, another_user2.id]
response.should redirect_to(redirect_path)
@repository.members.should include(@another_user, another_user2)
end
@ -194,19 +187,12 @@ shared_examples_for 'platform admin user' do
@repository.members.should include(@another_user)
end
it 'should be able to remove member from repository' do
create_relation(@repository, @another_user, 'admin')
delete :remove_member, id: @repository, platform_id: @platform, member_id: @another_user.id
response.should redirect_to(edit_platform_repository_path(@repository.platform, @repository))
@repository.members.should_not include(@another_user)
end
it 'should be able to remove members from repository' do
another_user2 = FactoryGirl.create(:user)
create_relation(@repository, @another_user, 'admin')
create_relation(@repository, @another_user2, 'admin')
create_relation(@repository, another_user2, 'admin')
post :remove_members, id: @repository, platform_id: @platform,
user_remove: {@another_user.id => [1], another_user2.id => [1]}
members: [@another_user.id, another_user2.id]
response.should redirect_to(edit_platform_repository_path(@repository.platform, @repository))
@repository.members.should_not include(@another_user, another_user2)
end