From 071518da8f1910cf7c45ad89187bcb59c180f02a Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 8 May 2013 00:25:31 +0600 Subject: [PATCH] [#125] move create specs to api --- spec/controllers/api/v1/projects_controller_spec.rb | 12 ++++++++++++ .../controllers/projects/projects_controller_spec.rb | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/controllers/api/v1/projects_controller_spec.rb b/spec/controllers/api/v1/projects_controller_spec.rb index f84a40a3d..b7991fab6 100644 --- a/spec/controllers/api/v1/projects_controller_spec.rb +++ b/spec/controllers/api/v1/projects_controller_spec.rb @@ -313,6 +313,18 @@ describe Api::V1::ProjectsController do it 'ensures that project has been created' do lambda { post :create, params, :format => :json }.should change{ Project.count }.by(1) end + + it 'writer group should be able to create project for their group' do + group = FactoryGirl.create(:group) + group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'writer') + lambda { post :create, params.deep_merge({:project => {:owner_type => 'Group', :owner_id => group.id}})}.should change{ Project.count }.by(1) + end + + it 'reader group should not be able to create project for their group' do + group = FactoryGirl.create(:group) + group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'reader') + lambda { post :create, params.deep_merge({:project => {:owner_type => 'Group', :owner_id => group.id}})}.should change{ Project.count }.by(0) + end end it_should_behave_like 'api projects user with reader rights' diff --git a/spec/controllers/projects/projects_controller_spec.rb b/spec/controllers/projects/projects_controller_spec.rb index a28d71f6e..07b57bb46 100644 --- a/spec/controllers/projects/projects_controller_spec.rb +++ b/spec/controllers/projects/projects_controller_spec.rb @@ -164,18 +164,6 @@ describe Projects::ProjectsController do group = FactoryGirl.create(:group, :owner => @user) lambda { post :create, @create_params.merge({:who_owns => 'group', :owner_id => group.id})}.should change{ Project.count }.by(1) end - - it 'writer group should be able to create project for their group' do - group = FactoryGirl.create(:group) - group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'writer') - lambda { post :create, @create_params.merge({:who_owns => 'group', :owner_id => group.id})}.should change{ Project.count }.by(1) - end - - it 'reader group should not be able to create project for their group' do - group = FactoryGirl.create(:group) - group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'reader') - lambda { post :create, @create_params.merge({:who_owns => 'group', :owner_id => group.id})}.should change{ Project.count }.by(0) - end end end # context 'registered user'