2018-12-17 04:53:17 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-08 15:32:08 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::ReleasesController do
|
2018-12-17 04:53:17 -05:00
|
|
|
let!(:project) { create(:project, :repository, :public) }
|
2016-12-08 15:32:08 -05:00
|
|
|
let!(:user) { create(:user) }
|
|
|
|
|
2018-12-17 04:53:17 -05:00
|
|
|
describe 'GET #index' do
|
|
|
|
it 'renders a 200' do
|
|
|
|
get_index
|
2016-12-08 15:32:08 -05:00
|
|
|
|
2018-12-17 04:53:17 -05:00
|
|
|
expect(response.status).to eq(200)
|
2016-12-08 15:32:08 -05:00
|
|
|
end
|
|
|
|
|
2018-12-17 04:53:17 -05:00
|
|
|
context 'when the project is private' do
|
|
|
|
let!(:project) { create(:project, :repository, :private) }
|
2016-12-08 15:32:08 -05:00
|
|
|
|
2018-12-17 04:53:17 -05:00
|
|
|
it 'renders a 302' do
|
|
|
|
get_index
|
|
|
|
|
|
|
|
expect(response.status).to eq(302)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders a 200 for a logged in developer' do
|
|
|
|
project.add_developer(user)
|
|
|
|
sign_in(user)
|
2016-12-08 15:32:08 -05:00
|
|
|
|
2018-12-17 04:53:17 -05:00
|
|
|
get_index
|
2016-12-08 15:32:08 -05:00
|
|
|
|
2018-12-17 04:53:17 -05:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders a 404 when logged in but not in the project' do
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
get_index
|
|
|
|
|
|
|
|
expect(response.status).to eq(404)
|
|
|
|
end
|
2016-12-08 15:32:08 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-17 04:53:17 -05:00
|
|
|
private
|
|
|
|
|
|
|
|
def get_index
|
2018-12-17 17:52:17 -05:00
|
|
|
get :index, params: { namespace_id: project.namespace, project_id: project }
|
2016-12-08 15:32:08 -05:00
|
|
|
end
|
|
|
|
end
|