2012-05-29 13:40:25 +01:00
|
|
|
# -*- encoding : utf-8 -*-
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
shared_examples_for 'guest user' do
|
2012-07-19 17:25:04 +01:00
|
|
|
|
2012-06-14 11:15:42 +01:00
|
|
|
# Only one action for now here
|
2012-07-19 17:25:04 +01:00
|
|
|
guest_actions = [:index]
|
|
|
|
|
|
|
|
if APP_CONFIG['anonymous_access']
|
|
|
|
guest_actions.each do |action|
|
|
|
|
it "should be able to perform #{ action } action" do
|
|
|
|
get action, :platform_id => @platform.id
|
|
|
|
response.should be_success
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else # non-anonymous access
|
|
|
|
guest_actions.each do |action|
|
|
|
|
it "should not be able to perform #{ action } action" do
|
|
|
|
get action, :platform_id => @platform.id
|
|
|
|
response.should redirect_to(new_user_session_path)
|
|
|
|
end
|
2012-05-29 13:40:25 +01:00
|
|
|
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-06-14 11:25:36 +01:00
|
|
|
# JS format is the primary target for this callback
|
|
|
|
@assignee_rq = { :platform_id => @platform.id, :package => 'test', :format => 'js' }
|
2012-05-31 12:43:40 +01:00
|
|
|
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
|
2012-06-14 11:25:36 +01:00
|
|
|
response.response_code.should == 403
|
2012-05-31 12:43:40 +01:00
|
|
|
end
|
2012-05-29 13:40:25 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|