abf/abf-ideas#83: added specs for Repository API

This commit is contained in:
Vokhmin Alexey V 2013-07-29 14:13:15 +04:00
parent afb0bb40e6
commit 16fdad15a5
3 changed files with 20 additions and 3 deletions

View File

@ -35,12 +35,12 @@ class Api::V1::RepositoriesController < Api::V1::BaseController
def start_sync
@repository.start_sync
render :nothing => true
render_json_response @repository, 'Repository has been locked for sync successfully'
end
def stop_sync
@repository.stop_sync
render :nothing => true
render_json_response @repository, 'Repository has been unlocked for sync successfully'
end
def add_project

View File

@ -62,6 +62,15 @@ shared_examples_for 'api repository user with writer rights' do
end
end
context 'api repository user with start/stop sync rights' do
[:start_sync, :stop_sync].each do |action|
it "should be able to perform #{action} action" do
put action, :id => @repository.id, :format => :json
response.should be_success
end
end
end
context 'api repository user with add_member rights' do
let(:member) { FactoryGirl.create(:user) }
before do
@ -179,6 +188,15 @@ shared_examples_for 'api repository user without writer rights' do
end
end
context 'api repository user without start/stop sync rights' do
[:start_sync, :stop_sync].each do |action|
it "should not be able to perform #{action} action" do
put action, :id => @repository.id, :format => :json
response.should_not be_success
end
end
end
context 'api repository user without add_member rights' do
let(:member) { FactoryGirl.create(:user) }
before do

View File

@ -20,7 +20,6 @@ shared_examples_for 'user with change projects in repository rights' do
@repository.projects.should_not include(@project)
end
end
shared_examples_for 'user with rights of lock/unlock sync of repository' do