Commit 31b68539 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'clarify_branches_controller_spec_naming' into 'master'

Clarify branches controller spec developer/user definitions

See merge request gitlab-org/gitlab!34279
parents 2713ff7e bbe8a16f
...@@ -8,8 +8,7 @@ RSpec.describe Projects::BranchesController do ...@@ -8,8 +8,7 @@ RSpec.describe Projects::BranchesController do
let(:developer) { create(:user) } let(:developer) { create(:user) }
before do before do
project.add_maintainer(user) project.add_developer(developer)
project.add_developer(user)
allow(project).to receive(:branches).and_return(['master', 'foo/bar/baz']) allow(project).to receive(:branches).and_return(['master', 'foo/bar/baz'])
allow(project).to receive(:tags).and_return(['v1.0.0', 'v2.0.0']) allow(project).to receive(:tags).and_return(['v1.0.0', 'v2.0.0'])
...@@ -21,7 +20,7 @@ RSpec.describe Projects::BranchesController do ...@@ -21,7 +20,7 @@ RSpec.describe Projects::BranchesController do
context "on creation of a new branch" do context "on creation of a new branch" do
before do before do
sign_in(user) sign_in(developer)
post :create, post :create,
params: { params: {
...@@ -80,7 +79,7 @@ RSpec.describe Projects::BranchesController do ...@@ -80,7 +79,7 @@ RSpec.describe Projects::BranchesController do
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
before do before do
sign_in(user) sign_in(developer)
end end
it 'redirects' do it 'redirects' do
...@@ -97,7 +96,7 @@ RSpec.describe Projects::BranchesController do ...@@ -97,7 +96,7 @@ RSpec.describe Projects::BranchesController do
end end
it 'posts a system note' do it 'posts a system note' do
expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, "1-feature-branch", branch_project: project) expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, developer, "1-feature-branch", branch_project: project)
post :create, post :create,
params: { params: {
...@@ -136,14 +135,14 @@ RSpec.describe Projects::BranchesController do ...@@ -136,14 +135,14 @@ RSpec.describe Projects::BranchesController do
context 'user can update issue' do context 'user can update issue' do
before do before do
confidential_issue_project.add_reporter(user) confidential_issue_project.add_reporter(developer)
end end
context 'issue is under the specified project' do context 'issue is under the specified project' do
let(:issue) { create(:issue, project: confidential_issue_project) } let(:issue) { create(:issue, project: confidential_issue_project) }
it 'posts a system note' do it 'posts a system note' do
expect(SystemNoteService).to receive(:new_issue_branch).with(issue, confidential_issue_project, user, "1-feature-branch", branch_project: project) expect(SystemNoteService).to receive(:new_issue_branch).with(issue, confidential_issue_project, developer, "1-feature-branch", branch_project: project)
create_branch_with_confidential_issue_project create_branch_with_confidential_issue_project
end end
...@@ -264,7 +263,7 @@ RSpec.describe Projects::BranchesController do ...@@ -264,7 +263,7 @@ RSpec.describe Projects::BranchesController do
describe 'POST create with JSON format' do describe 'POST create with JSON format' do
before do before do
sign_in(user) sign_in(developer)
end end
context 'with valid params' do context 'with valid params' do
...@@ -305,7 +304,7 @@ RSpec.describe Projects::BranchesController do ...@@ -305,7 +304,7 @@ RSpec.describe Projects::BranchesController do
render_views render_views
before do before do
sign_in(user) sign_in(developer)
end end
it 'returns 303' do it 'returns 303' do
...@@ -325,7 +324,7 @@ RSpec.describe Projects::BranchesController do ...@@ -325,7 +324,7 @@ RSpec.describe Projects::BranchesController do
render_views render_views
before do before do
sign_in(user) sign_in(developer)
post :destroy, post :destroy,
format: format, format: format,
...@@ -436,7 +435,7 @@ RSpec.describe Projects::BranchesController do ...@@ -436,7 +435,7 @@ RSpec.describe Projects::BranchesController do
context 'when user is allowed to push' do context 'when user is allowed to push' do
before do before do
sign_in(user) sign_in(developer)
end end
it 'redirects to branches' do it 'redirects to branches' do
...@@ -454,7 +453,7 @@ RSpec.describe Projects::BranchesController do ...@@ -454,7 +453,7 @@ RSpec.describe Projects::BranchesController do
context 'when user is not allowed to push' do context 'when user is not allowed to push' do
before do before do
sign_in(developer) sign_in(user)
end end
it 'responds with status 404' do it 'responds with status 404' do
...@@ -469,7 +468,7 @@ RSpec.describe Projects::BranchesController do ...@@ -469,7 +468,7 @@ RSpec.describe Projects::BranchesController do
render_views render_views
before do before do
sign_in(user) sign_in(developer)
end end
context 'when rendering a JSON format' do context 'when rendering a JSON format' do
...@@ -564,7 +563,7 @@ RSpec.describe Projects::BranchesController do ...@@ -564,7 +563,7 @@ RSpec.describe Projects::BranchesController do
describe 'GET diverging_commit_counts' do describe 'GET diverging_commit_counts' do
before do before do
sign_in(user) sign_in(developer)
end end
it 'returns the commit counts behind and ahead of default branch' do it 'returns the commit counts behind and ahead of default branch' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment