|
|
|
@ -30,13 +30,13 @@ require 'spec_helper' |
|
|
|
|
|
|
|
|
|
describe SysController, type: :controller do |
|
|
|
|
let(:commit_role) { |
|
|
|
|
FactoryGirl.create(:role, permissions: %i[commit_access browse_repository]) |
|
|
|
|
FactoryBot.create(:role, permissions: %i[commit_access browse_repository]) |
|
|
|
|
} |
|
|
|
|
let(:browse_role) { FactoryGirl.create(:role, permissions: [:browse_repository]) } |
|
|
|
|
let(:guest_role) { FactoryGirl.create(:role, permissions: []) } |
|
|
|
|
let(:browse_role) { FactoryBot.create(:role, permissions: [:browse_repository]) } |
|
|
|
|
let(:guest_role) { FactoryBot.create(:role, permissions: []) } |
|
|
|
|
let(:valid_user_password) { 'Top Secret Password' } |
|
|
|
|
let(:valid_user) { |
|
|
|
|
FactoryGirl.create(:user, |
|
|
|
|
FactoryBot.create(:user, |
|
|
|
|
login: 'johndoe', |
|
|
|
|
password: valid_user_password, |
|
|
|
|
password_confirmation: valid_user_password) |
|
|
|
@ -45,14 +45,14 @@ describe SysController, type: :controller do |
|
|
|
|
let(:api_key) { '12345678' } |
|
|
|
|
|
|
|
|
|
let(:public) { false } |
|
|
|
|
let(:project) { FactoryGirl.create(:project, is_public: public) } |
|
|
|
|
let(:project) { FactoryBot.create(:project, is_public: public) } |
|
|
|
|
|
|
|
|
|
before(:each) do |
|
|
|
|
FactoryGirl.create(:non_member, permissions: [:browse_repository]) |
|
|
|
|
FactoryBot.create(:non_member, permissions: [:browse_repository]) |
|
|
|
|
DeletedUser.first # creating it first in order to avoid problems with should_receive |
|
|
|
|
|
|
|
|
|
random_project = FactoryGirl.create(:project, is_public: false) |
|
|
|
|
FactoryGirl.create(:member, |
|
|
|
|
random_project = FactoryBot.create(:project, is_public: false) |
|
|
|
|
FactoryBot.create(:member, |
|
|
|
|
user: valid_user, |
|
|
|
|
roles: [browse_role], |
|
|
|
|
project: random_project) |
|
|
|
@ -65,7 +65,7 @@ describe SysController, type: :controller do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'svn' do |
|
|
|
|
let!(:repository) { FactoryGirl.create(:repository_subversion, project: project) } |
|
|
|
|
let!(:repository) { FactoryBot.create(:repository_subversion, project: project) } |
|
|
|
|
|
|
|
|
|
describe 'repo_auth' do |
|
|
|
|
context 'for valid login, but no access to repo_auth' do |
|
|
|
@ -89,7 +89,7 @@ describe SysController, type: :controller do |
|
|
|
|
|
|
|
|
|
context 'for valid login and user has read permission (role reporter) for project' do |
|
|
|
|
before(:each) do |
|
|
|
|
FactoryGirl.create(:member, |
|
|
|
|
FactoryBot.create(:member, |
|
|
|
|
user: valid_user, |
|
|
|
|
roles: [browse_role], |
|
|
|
|
project: project) |
|
|
|
@ -120,7 +120,7 @@ describe SysController, type: :controller do |
|
|
|
|
|
|
|
|
|
context 'for valid login and user has rw permission (role developer) for project' do |
|
|
|
|
before(:each) do |
|
|
|
|
FactoryGirl.create(:member, |
|
|
|
|
FactoryBot.create(:member, |
|
|
|
|
user: valid_user, |
|
|
|
|
roles: [commit_role], |
|
|
|
|
project: project) |
|
|
|
@ -151,7 +151,7 @@ describe SysController, type: :controller do |
|
|
|
|
|
|
|
|
|
context 'for invalid login and user has role manager for project' do |
|
|
|
|
before(:each) do |
|
|
|
|
FactoryGirl.create(:member, |
|
|
|
|
FactoryBot.create(:member, |
|
|
|
|
user: valid_user, |
|
|
|
|
roles: [commit_role], |
|
|
|
|
project: project) |
|
|
|
@ -193,8 +193,8 @@ describe SysController, type: :controller do |
|
|
|
|
let(:public) { true } |
|
|
|
|
|
|
|
|
|
before(:each) do |
|
|
|
|
random_project = FactoryGirl.create(:project, is_public: false) |
|
|
|
|
FactoryGirl.create(:member, |
|
|
|
|
random_project = FactoryBot.create(:project, is_public: false) |
|
|
|
|
FactoryBot.create(:member, |
|
|
|
|
user: valid_user, |
|
|
|
|
roles: [browse_role], |
|
|
|
|
project: random_project) |
|
|
|
@ -264,7 +264,7 @@ describe SysController, type: :controller do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'git' do |
|
|
|
|
let!(:repository) { FactoryGirl.create(:repository_git, project: project) } |
|
|
|
|
let!(:repository) { FactoryBot.create(:repository_git, project: project) } |
|
|
|
|
describe 'repo_auth' do |
|
|
|
|
context 'for valid login, but no access to repo_auth' do |
|
|
|
|
before(:each) do |
|
|
|
@ -290,7 +290,7 @@ describe SysController, type: :controller do |
|
|
|
|
|
|
|
|
|
context 'for valid login and user has read permission (role reporter) for project' do |
|
|
|
|
before(:each) do |
|
|
|
|
FactoryGirl.create(:member, |
|
|
|
|
FactoryBot.create(:member, |
|
|
|
|
user: valid_user, |
|
|
|
|
roles: [browse_role], |
|
|
|
|
project: project) |
|
|
|
@ -327,7 +327,7 @@ describe SysController, type: :controller do |
|
|
|
|
|
|
|
|
|
context 'for valid login and user has rw permission (role developer) for project' do |
|
|
|
|
before(:each) do |
|
|
|
|
FactoryGirl.create(:member, |
|
|
|
|
FactoryBot.create(:member, |
|
|
|
|
user: valid_user, |
|
|
|
|
roles: [commit_role], |
|
|
|
|
project: project) |
|
|
|
@ -365,7 +365,7 @@ describe SysController, type: :controller do |
|
|
|
|
|
|
|
|
|
context 'for invalid login and user has role manager for project' do |
|
|
|
|
before(:each) do |
|
|
|
|
FactoryGirl.create(:member, |
|
|
|
|
FactoryBot.create(:member, |
|
|
|
|
user: valid_user, |
|
|
|
|
roles: [commit_role], |
|
|
|
|
project: project) |
|
|
|
@ -391,7 +391,7 @@ describe SysController, type: :controller do |
|
|
|
|
|
|
|
|
|
context 'for valid login and user is not member for project' do |
|
|
|
|
before(:each) do |
|
|
|
|
project = FactoryGirl.create(:project, is_public: false) |
|
|
|
|
project = FactoryBot.create(:project, is_public: false) |
|
|
|
|
request.env['HTTP_AUTHORIZATION'] = |
|
|
|
|
ActionController::HttpAuthentication::Basic.encode_credentials( |
|
|
|
|
valid_user.login, |
|
|
|
@ -414,8 +414,8 @@ describe SysController, type: :controller do |
|
|
|
|
context 'for valid login and project is public' do |
|
|
|
|
let(:public) { true } |
|
|
|
|
before(:each) do |
|
|
|
|
random_project = FactoryGirl.create(:project, is_public: false) |
|
|
|
|
FactoryGirl.create(:member, |
|
|
|
|
random_project = FactoryBot.create(:project, is_public: false) |
|
|
|
|
FactoryBot.create(:member, |
|
|
|
|
user: valid_user, |
|
|
|
|
roles: [browse_role], |
|
|
|
|
project: random_project) |
|
|
|
@ -562,7 +562,7 @@ describe SysController, type: :controller do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'available project, but missing repository' do |
|
|
|
|
let(:project) { FactoryGirl.build_stubbed(:project) } |
|
|
|
|
let(:project) { FactoryBot.build_stubbed(:project) } |
|
|
|
|
let(:id) { project.id } |
|
|
|
|
before do |
|
|
|
|
allow(Project).to receive(:find).and_return(project) |
|
|
|
@ -576,10 +576,10 @@ describe SysController, type: :controller do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'stubbed repository' do |
|
|
|
|
let(:project) { FactoryGirl.build_stubbed(:project) } |
|
|
|
|
let(:project) { FactoryBot.build_stubbed(:project) } |
|
|
|
|
let(:id) { project.id } |
|
|
|
|
let(:repository) { |
|
|
|
|
FactoryGirl.build_stubbed(:repository_subversion, url: url, root_url: url) |
|
|
|
|
FactoryBot.build_stubbed(:repository_subversion, url: url, root_url: url) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
@ -617,10 +617,10 @@ describe SysController, type: :controller do |
|
|
|
|
let(:root_url) { repo_dir } |
|
|
|
|
let(:url) { "file://#{root_url}" } |
|
|
|
|
|
|
|
|
|
let(:project) { FactoryGirl.create(:project) } |
|
|
|
|
let(:project) { FactoryBot.create(:project) } |
|
|
|
|
let(:id) { project.id } |
|
|
|
|
let(:repository) { |
|
|
|
|
FactoryGirl.create(:repository_subversion, project: project, url: url, root_url: url) |
|
|
|
|
FactoryBot.create(:repository_subversion, project: project, url: url, root_url: url) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|