Commit 3914af2f authored by Rémy Coutable's avatar Rémy Coutable

Use set in some API specs

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 6ab74da9
require 'spec_helper'
describe API::AccessRequests do
let(:master) { create(:user) }
let(:developer) { create(:user) }
let(:access_requester) { create(:user) }
let(:stranger) { create(:user) }
set(:master) { create(:user) }
set(:developer) { create(:user) }
set(:access_requester) { create(:user) }
set(:stranger) { create(:user) }
let(:project) do
set(:project) do
create(:project, :public, :access_requestable, creator_id: master.id, namespace: master.namespace) do |project|
project.team << [developer, :developer]
project.team << [master, :master]
......@@ -14,7 +14,7 @@ describe API::AccessRequests do
end
end
let(:group) do
set(:group) do
create(:group, :public, :access_requestable) do |group|
group.add_developer(developer)
group.add_owner(master)
......
require 'spec_helper'
describe API::AwardEmoji do
let(:user) { create(:user) }
let!(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
let!(:award_emoji) { create(:award_emoji, awardable: issue, user: user) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:downvote) { create(:award_emoji, :downvote, awardable: merge_request, user: user) }
let!(:note) { create(:note, project: project, noteable: issue) }
set(:user) { create(:user) }
set(:project) { create(:project) }
set(:issue) { create(:issue, project: project) }
set(:award_emoji) { create(:award_emoji, awardable: issue, user: user) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:downvote) { create(:award_emoji, :downvote, awardable: merge_request, user: user) }
set(:note) { create(:note, project: project, noteable: issue) }
before do
project.team << [user, :master]
......
require 'spec_helper'
describe API::Boards do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:non_member) { create(:user) }
let(:guest) { create(:user) }
let(:admin) { create(:user, :admin) }
let!(:project) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) }
let!(:dev_label) do
set(:user) { create(:user) }
set(:user2) { create(:user) }
set(:non_member) { create(:user) }
set(:guest) { create(:user) }
set(:admin) { create(:user, :admin) }
set(:project) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) }
set(:dev_label) do
create(:label, title: 'Development', color: '#FFAABB', project: project)
end
let!(:test_label) do
set(:test_label) do
create(:label, title: 'Testing', color: '#FFAACC', project: project)
end
let!(:ux_label) do
set(:ux_label) do
create(:label, title: 'UX', color: '#FF0000', project: project)
end
let!(:dev_list) do
set(:dev_list) do
create(:list, label: dev_label, position: 1)
end
let!(:test_list) do
set(:test_list) do
create(:list, label: test_label, position: 2)
end
let!(:board) do
set(:board) do
create(:board, project: project, lists: [dev_list, test_list])
end
......@@ -187,8 +187,11 @@ describe API::Boards do
end
context "when the user is project owner" do
let(:owner) { create(:user) }
let(:project) { create(:project, namespace: owner.namespace) }
set(:owner) { create(:user) }
before do
project.update(namespace: owner.namespace)
end
it "deletes the list if an admin requests it" do
delete api("#{base_url}/#{dev_list.id}", owner)
......
require 'spec_helper'
describe API::Branches do
let(:user) { create(:user) }
let(:guest) { create(:user).tap { |u| project.add_guest(u) } }
set(:user) { create(:user) }
let(:project) { create(:project, :repository, creator: user, path: 'my.project') }
let(:guest) { create(:user).tap { |u| project.add_guest(u) } }
let(:branch_name) { 'feature' }
let(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' }
let(:branch_with_dot) { project.repository.find_branch('ends-with.json') }
......@@ -40,7 +40,9 @@ describe API::Branches do
end
context 'when unauthenticated', 'and project is public' do
let(:project) { create(:project, :public, :repository) }
before do
project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
end
it_behaves_like 'repository branches'
end
......@@ -118,7 +120,9 @@ describe API::Branches do
end
context 'when unauthenticated', 'and project is public' do
let(:project) { create(:project, :public, :repository) }
before do
project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
end
it_behaves_like 'repository branch'
end
......
require 'spec_helper'
describe API::BroadcastMessages do
let(:user) { create(:user) }
let(:admin) { create(:admin) }
set(:user) { create(:user) }
set(:admin) { create(:admin) }
set(:message) { create(:broadcast_message) }
describe 'GET /broadcast_messages' do
it 'returns a 401 for anonymous users' do
......@@ -31,8 +32,6 @@ describe API::BroadcastMessages do
end
describe 'GET /broadcast_messages/:id' do
let!(:message) { create(:broadcast_message) }
it 'returns a 401 for anonymous users' do
get api("/broadcast_messages/#{message.id}")
......@@ -103,8 +102,6 @@ describe API::BroadcastMessages do
end
describe 'PUT /broadcast_messages/:id' do
let!(:message) { create(:broadcast_message) }
it 'returns a 401 for anonymous users' do
put api("/broadcast_messages/#{message.id}"),
attributes_for(:broadcast_message)
......@@ -155,8 +152,6 @@ describe API::BroadcastMessages do
end
describe 'DELETE /broadcast_messages/:id' do
let!(:message) { create(:broadcast_message) }
it 'returns a 401 for anonymous users' do
delete api("/broadcast_messages/#{message.id}"),
attributes_for(:broadcast_message)
......
require 'spec_helper'
describe API::V3::AwardEmoji do
let(:user) { create(:user) }
let!(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
let!(:award_emoji) { create(:award_emoji, awardable: issue, user: user) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:downvote) { create(:award_emoji, :downvote, awardable: merge_request, user: user) }
let!(:note) { create(:note, project: project, noteable: issue) }
set(:user) { create(:user) }
set(:project) { create(:project) }
set(:issue) { create(:issue, project: project) }
set(:award_emoji) { create(:award_emoji, awardable: issue, user: user) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:downvote) { create(:award_emoji, :downvote, awardable: merge_request, user: user) }
set(:note) { create(:note, project: project, noteable: issue) }
before { project.team << [user, :master] }
......
require 'spec_helper'
describe API::V3::Boards do
let(:user) { create(:user) }
let(:guest) { create(:user) }
let(:non_member) { create(:user) }
let!(:project) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) }
set(:user) { create(:user) }
set(:guest) { create(:user) }
set(:non_member) { create(:user) }
set(:project) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) }
let!(:dev_label) do
set(:dev_label) do
create(:label, title: 'Development', color: '#FFAABB', project: project)
end
let!(:test_label) do
set(:test_label) do
create(:label, title: 'Testing', color: '#FFAACC', project: project)
end
let!(:dev_list) do
set(:dev_list) do
create(:list, label: dev_label, position: 1)
end
let!(:test_list) do
set(:test_list) do
create(:list, label: test_label, position: 2)
end
let!(:board) do
set(:board) do
create(:board, project: project, lists: [dev_list, test_list])
end
......@@ -98,8 +98,11 @@ describe API::V3::Boards do
end
context "when the user is project owner" do
let(:owner) { create(:user) }
let(:project) { create(:project, namespace: owner.namespace) }
set(:owner) { create(:user) }
before do
project.update(namespace: owner.namespace)
end
it "deletes the list if an admin requests it" do
delete v3_api("#{base_url}/#{dev_list.id}", owner)
......
......@@ -2,11 +2,11 @@ require 'spec_helper'
require 'mime/types'
describe API::V3::Branches do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let!(:project) { create(:project, :repository, creator: user) }
let!(:master) { create(:project_member, :master, user: user, project: project) }
let!(:guest) { create(:project_member, :guest, user: user2, project: project) }
set(:user) { create(:user) }
set(:user2) { create(:user) }
set(:project) { create(:project, :repository, creator: user) }
set(:master) { create(:project_member, :master, user: user, project: project) }
set(:guest) { create(:project_member, :guest, user: user2, project: project) }
let!(:branch_name) { 'feature' }
let!(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' }
let!(:branch_with_dot) { CreateBranchService.new(project, user).execute("with.1.2.3", "master") }
......
require 'spec_helper'
describe API::V3::BroadcastMessages do
let(:user) { create(:user) }
let(:admin) { create(:admin) }
set(:user) { create(:user) }
set(:admin) { create(:admin) }
describe 'DELETE /broadcast_messages/:id' do
let!(:message) { create(:broadcast_message) }
set(:message) { create(:broadcast_message) }
it 'returns a 401 for anonymous users' do
delete v3_api("/broadcast_messages/#{message.id}"),
......
require 'spec_helper'
describe API::V3::Builds do
let(:user) { create(:user) }
set(:user) { create(:user) }
let(:api_user) { user }
let!(:project) { create(:project, :repository, creator: user, public_builds: false) }
let!(:developer) { create(:project_member, :developer, user: user, project: project) }
let(:reporter) { create(:project_member, :reporter, project: project) }
let(:guest) { create(:project_member, :guest, project: project) }
let!(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id, ref: project.default_branch) }
set(:project) { create(:project, :repository, creator: user, public_builds: false) }
set(:developer) { create(:project_member, :developer, user: user, project: project) }
set(:reporter) { create(:project_member, :reporter, project: project) }
set(:guest) { create(:project_member, :guest, project: project) }
set(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id, ref: project.default_branch) }
let!(:build) { create(:ci_build, pipeline: pipeline) }
describe 'GET /projects/:id/builds ' do
......
require 'spec_helper'
describe API::V3::Issues, :mailer do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:non_member) { create(:user) }
let(:guest) { create(:user) }
let(:author) { create(:author) }
let(:assignee) { create(:assignee) }
let(:admin) { create(:user, :admin) }
set(:user) { create(:user) }
set(:user2) { create(:user) }
set(:non_member) { create(:user) }
set(:guest) { create(:user) }
set(:author) { create(:author) }
set(:assignee) { create(:assignee) }
set(:admin) { create(:user, :admin) }
let!(:project) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) }
let!(:closed_issue) do
create :closed_issue,
......@@ -822,7 +822,8 @@ describe API::V3::Issues, :mailer do
end
context 'resolving issues in a merge request' do
let(:discussion) { create(:diff_note_on_merge_request).to_discussion }
set(:diff_note_on_merge_request) { create(:diff_note_on_merge_request) }
let(:discussion) { diff_note_on_merge_request.to_discussion }
let(:merge_request) { discussion.noteable }
let(:project) { merge_request.source_project }
before do
......@@ -1169,7 +1170,7 @@ describe API::V3::Issues, :mailer do
end
context "when the user is project owner" do
let(:owner) { create(:user) }
set(:owner) { create(:user) }
let(:project) { create(:project, namespace: owner.namespace) }
it "deletes the issue if an admin requests it" 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