2012-05-29 13:40:25 +01:00
|
|
|
# -*- encoding : utf-8 -*-
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
shared_examples_for 'guest user' do
|
|
|
|
before(:each) do
|
|
|
|
if APP_CONFIG['anonymous_access']
|
|
|
|
else
|
|
|
|
@user = FactoryGirl.create(:user)
|
|
|
|
set_session_for(@user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
[:index].each do |action|
|
|
|
|
it "should be able to perform #{ action } action" do
|
|
|
|
get action, :platform_id => @platform.id
|
|
|
|
response.should be_success
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe Platforms::MaintainersController do
|
2012-05-31 12:43:40 +01:00
|
|
|
before(:each) do
|
2012-05-29 13:40:25 +01:00
|
|
|
stub_symlink_methods
|
|
|
|
|
|
|
|
@platform = FactoryGirl.create(:platform)
|
|
|
|
@platform.visibility = 'open'
|
|
|
|
|
2012-05-31 12:43:40 +01:00
|
|
|
@assignee_rq = { :platform_id => @platform.id, :package => 'test' }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for guest' do
|
2012-05-29 13:40:25 +01:00
|
|
|
it_should_behave_like 'guest user'
|
2012-05-31 12:43:40 +01:00
|
|
|
|
|
|
|
it 'should not be able to get api' do
|
|
|
|
get :assignee, @assignee_rq
|
|
|
|
puts response.headers.inspect
|
|
|
|
response.response_code.should equal(403)
|
|
|
|
end
|
2012-05-29 13:40:25 +01:00
|
|
|
end
|
|
|
|
|
2012-05-31 12:43:40 +01:00
|
|
|
context 'for bugzilla' do
|
|
|
|
before(:each) do
|
|
|
|
request.remote_addr = APP_CONFIG['external_tracker_ip']
|
|
|
|
end
|
|
|
|
|
|
|
|
it_should_behave_like 'guest user'
|
|
|
|
|
|
|
|
it 'should be able to get api' do
|
|
|
|
get :assignee, @assignee_rq
|
|
|
|
response.response_code.should equal(200)
|
|
|
|
end
|
|
|
|
end
|
2012-05-29 13:40:25 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|