Commit a781e129 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'pl-speedup-snippet-specs' into 'master'

Speed up snippet finder specs

See merge request gitlab-org/gitlab!16985
parents 856c22eb df9a3d18
...@@ -11,13 +11,21 @@ RSpec.shared_examples 'snippet visibility' do ...@@ -11,13 +11,21 @@ RSpec.shared_examples 'snippet visibility' do
set(:author) { create(:user) } set(:author) { create(:user) }
set(:member) { create(:user) } set(:member) { create(:user) }
set(:external) { create(:user, :external) } set(:external) { create(:user, :external) }
set(:non_member) { create(:user) }
set(:project) do
create(:project).tap do |project|
project.add_developer(author)
project.add_developer(member)
end
end
context "For project snippets" do context "For project snippets" do
let!(:users) do let!(:users) do
{ {
unauthenticated: nil, unauthenticated: nil,
external: external, external: external,
non_member: create(:user), non_member: non_member,
member: member, member: member,
author: author author: author
} }
...@@ -211,14 +219,18 @@ RSpec.shared_examples 'snippet visibility' do ...@@ -211,14 +219,18 @@ RSpec.shared_examples 'snippet visibility' do
end end
with_them do with_them do
let!(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel.level_value(project_type.to_s)) } let!(:project_visibility) { project.update_column(:visibility_level, Gitlab::VisibilityLevel.level_value(project_type.to_s)) }
let!(:project_feature) { project.project_feature.update_column(:snippets_access_level, feature_visibility) } let!(:project_feature) { project.project_feature.update_column(:snippets_access_level, feature_visibility) }
let!(:user) { users[user_type] } let!(:user) { users[user_type] }
let!(:snippet) { create(:project_snippet, visibility_level: snippet_type, project: project, author: author) } let!(:snippet) { create(:project_snippet, visibility_level: snippet_type, project: project, author: author) }
let!(:members) do let!(:external_member) do
project.add_developer(author) member = project.project_member(external)
project.add_developer(member)
project.add_developer(external) if project.private? if project.private?
project.add_developer(external) unless member
else
member.delete if member
end
end end
context "For #{params[:project_type]} project and #{params[:user_type]} users" do context "For #{params[:project_type]} project and #{params[:user_type]} users" do
...@@ -256,7 +268,7 @@ RSpec.shared_examples 'snippet visibility' do ...@@ -256,7 +268,7 @@ RSpec.shared_examples 'snippet visibility' do
{ {
unauthenticated: nil, unauthenticated: nil,
external: external, external: external,
non_member: create(:user), non_member: non_member,
author: author author: author
} }
end end
......
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