2019-02-13 22:33:31 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::ReleasesController do
|
2019-02-13 22:33:31 +05:30
|
|
|
let!(:project) { create(:project, :repository, :public) }
|
2017-08-17 22:00:37 +05:30
|
|
|
let!(:user) { create(:user) }
|
|
|
|
|
2019-02-13 22:33:31 +05:30
|
|
|
describe 'GET #index' do
|
|
|
|
it 'renders a 200' do
|
|
|
|
get_index
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-02-13 22:33:31 +05:30
|
|
|
expect(response.status).to eq(200)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-02-13 22:33:31 +05:30
|
|
|
context 'when the project is private' do
|
|
|
|
let!(:project) { create(:project, :repository, :private) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-02-13 22:33:31 +05:30
|
|
|
it 'renders a 302' do
|
|
|
|
get_index
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-02-13 22:33:31 +05:30
|
|
|
expect(response.status).to eq(302)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-02-13 22:33:31 +05:30
|
|
|
it 'renders a 200 for a logged in developer' do
|
|
|
|
project.add_developer(user)
|
|
|
|
sign_in(user)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-02-13 22:33:31 +05:30
|
|
|
get_index
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-02-13 22:33:31 +05:30
|
|
|
expect(response.status).to eq(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders a 404 when logged in but not in the project' do
|
|
|
|
sign_in(user)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-02-13 22:33:31 +05:30
|
|
|
get_index
|
|
|
|
|
|
|
|
expect(response.status).to eq(404)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-02-13 22:33:31 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def get_index
|
|
|
|
get :index, params: { namespace_id: project.namespace, project_id: project }
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|