Merge pull request #191 from abf/rosa-build:70-maintaiers-api
#70: Error in maintaiers API documentation
This commit is contained in:
commit
c993d3dcec
|
@ -5,7 +5,7 @@ class Api::V1::MaintainersController < Api::V1::BaseController
|
||||||
def index
|
def index
|
||||||
@maintainers = BuildList::Package.includes(:project)
|
@maintainers = BuildList::Package.includes(:project)
|
||||||
.actual.by_platform(@platform)
|
.actual.by_platform(@platform)
|
||||||
.like_name(params[:filter].try(:[], :package_name))
|
.like_name(params[:package_name])
|
||||||
.paginate(paginate_params)
|
.paginate(paginate_params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,32 +1,50 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Api::V1::MaintainersController do
|
shared_examples_for 'api maintainers user with reader rights' do
|
||||||
before do
|
it 'should be able to perform index action' do
|
||||||
stub_symlink_methods
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:package) { FactoryGirl.create(:build_list_package) }
|
|
||||||
|
|
||||||
context 'for guest' do
|
|
||||||
it "should be able to perform index action", :anonymous_access => true do
|
|
||||||
get :index, :platform_id => package.platform_id, :format => :json
|
get :index, :platform_id => package.platform_id, :format => :json
|
||||||
should render_template(:index)
|
should render_template(:index)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to perform get_id action', :anonymous_access => false do
|
it 'loads all of the maintainers into @maintainers' do
|
||||||
|
get :index, :platform_id => package.platform_id, :format => :json
|
||||||
|
assigns(:maintainers).should have(2).items
|
||||||
|
assigns(:maintainers).should include(package, package2)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'loads all of the maintainers into @maintainers when search by name' do
|
||||||
|
get :index, :platform_id => package.platform_id, :package_name => 'package1', :format => :json
|
||||||
|
assigns(:maintainers).should have(1).item
|
||||||
|
assigns(:maintainers).should include(package)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe Api::V1::MaintainersController do
|
||||||
|
before do
|
||||||
|
stub_symlink_methods
|
||||||
|
FactoryGirl.create(:build_list_package, :platform => package.platform)
|
||||||
|
end
|
||||||
|
let(:package) { FactoryGirl.create(:build_list_package, :name => 'package1', :actual => true) }
|
||||||
|
let!(:package2) { FactoryGirl.create(:build_list_package, :platform => package.platform, :actual => true) }
|
||||||
|
|
||||||
|
|
||||||
|
context 'for guest' do
|
||||||
|
if APP_CONFIG['anonymous_access']
|
||||||
|
it_should_behave_like 'api maintainers user with reader rights'
|
||||||
|
else
|
||||||
|
it 'should not be able to perform index action', :anonymous_access => false do
|
||||||
get :index, :platform_id => package.platform_id, :format => :json
|
get :index, :platform_id => package.platform_id, :format => :json
|
||||||
response.status.should == 401
|
response.status.should == 401
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'for simple user' do
|
context 'for simple user' do
|
||||||
before do
|
before do
|
||||||
http_login(FactoryGirl.create(:user))
|
http_login(FactoryGirl.create(:user))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be able to perform index action" do
|
it_should_behave_like 'api maintainers user with reader rights'
|
||||||
get :index, :platform_id => package.platform_id, :format => :json
|
|
||||||
should render_template(:index)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue