Commit cd401a58 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'winh-deterministic-frontend-fixtures' into 'master'

Make frontend fixtures deterministic

See merge request gitlab-org/gitlab-ce!23705
parents cf8c2eeb 7e0507dc
...@@ -15,6 +15,7 @@ describe Projects::BlobController, '(JavaScript fixtures)', type: :controller do ...@@ -15,6 +15,7 @@ describe Projects::BlobController, '(JavaScript fixtures)', type: :controller do
before do before do
sign_in(admin) sign_in(admin)
allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon')
end end
after do after do
......
...@@ -16,6 +16,7 @@ describe Projects::CommitController, '(JavaScript fixtures)', type: :controller ...@@ -16,6 +16,7 @@ describe Projects::CommitController, '(JavaScript fixtures)', type: :controller
before do before do
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user) sign_in(user)
allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon')
end end
it 'commit/show.html.raw' do |example| it 'commit/show.html.raw' do |example|
......
...@@ -25,7 +25,7 @@ describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :control ...@@ -25,7 +25,7 @@ describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :control
render_views render_views
it 'deploy_keys/keys.json' do |example| it 'deploy_keys/keys.json' do |example|
create(:deploy_key, public: true) create(:rsa_deploy_key_2048, public: true)
project_key = create(:deploy_key, key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCdMHEHyhRjbhEZVddFn6lTWdgEy5Q6Bz4nwGB76xWZI5YT/1WJOMEW+sL5zYd31kk7sd3FJ5L9ft8zWMWrr/iWXQikC2cqZK24H1xy+ZUmrRuJD4qGAaIVoyyzBL+avL+lF8J5lg6YSw8gwJY/lX64/vnJHUlWw2n5BF8IFOWhiw== dummy@gitlab.com') project_key = create(:deploy_key, key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCdMHEHyhRjbhEZVddFn6lTWdgEy5Q6Bz4nwGB76xWZI5YT/1WJOMEW+sL5zYd31kk7sd3FJ5L9ft8zWMWrr/iWXQikC2cqZK24H1xy+ZUmrRuJD4qGAaIVoyyzBL+avL+lF8J5lg6YSw8gwJY/lX64/vnJHUlWw2n5BF8IFOWhiw== dummy@gitlab.com')
internal_key = create(:deploy_key, key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNd/UJWhPrpb+b/G5oL109y57yKuCxE+WUGJGYaj7WQKsYRJmLYh1mgjrl+KVyfsWpq4ylOxIfFSnN9xBBFN8mlb0Fma5DC7YsSsibJr3MZ19ZNBprwNcdogET7aW9I0In7Wu5f2KqI6e5W/spJHCy4JVxzVMUvk6Myab0LnJ2iQ== dummy@gitlab.com') internal_key = create(:deploy_key, key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNd/UJWhPrpb+b/G5oL109y57yKuCxE+WUGJGYaj7WQKsYRJmLYh1mgjrl+KVyfsWpq4ylOxIfFSnN9xBBFN8mlb0Fma5DC7YsSsibJr3MZ19ZNBprwNcdogET7aW9I0In7Wu5f2KqI6e5W/spJHCy4JVxzVMUvk6Myab0LnJ2iQ== dummy@gitlab.com')
create(:deploy_keys_project, project: project, deploy_key: project_key) create(:deploy_keys_project, project: project, deploy_key: project_key)
......
...@@ -4,7 +4,7 @@ describe 'Groups (JavaScript fixtures)', type: :controller do ...@@ -4,7 +4,7 @@ describe 'Groups (JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:group) { create(:group, name: 'frontend-fixtures-group' )} let(:group) { create(:group, name: 'frontend-fixtures-group', runners_token: 'runnerstoken:intabulasreferre')}
render_views render_views
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller do describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:admin) { create(:admin) } let(:admin) { create(:admin, feed_token: 'feedtoken:coldfeed') }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project_empty_repo, namespace: namespace, path: 'issues-project') } let(:project) { create(:project_empty_repo, namespace: namespace, path: 'issues-project') }
......
...@@ -35,6 +35,7 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont ...@@ -35,6 +35,7 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
before do before do
sign_in(admin) sign_in(admin)
allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo'])
end end
after do after do
...@@ -54,8 +55,10 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont ...@@ -54,8 +55,10 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
end end
it 'merge_requests/merged_merge_request.html.raw' do |example| it 'merge_requests/merged_merge_request.html.raw' do |example|
allow_any_instance_of(MergeRequest).to receive(:source_branch_exists?).and_return(true) expect_next_instance_of(MergeRequest) do |merge_request|
allow_any_instance_of(MergeRequest).to receive(:can_remove_source_branch?).and_return(true) allow(merge_request).to receive(:source_branch_exists?).and_return(true)
allow(merge_request).to receive(:can_remove_source_branch?).and_return(true)
end
render_merge_request(example.description, merged_merge_request) render_merge_request(example.description, merged_merge_request)
end end
......
...@@ -3,13 +3,13 @@ require 'spec_helper' ...@@ -3,13 +3,13 @@ require 'spec_helper'
describe 'Projects (JavaScript fixtures)', type: :controller do describe 'Projects (JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
runners_token = 'runnerstoken:intabulasreferre'
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, namespace: namespace, path: 'builds-project') } let(:project) { create(:project, namespace: namespace, path: 'builds-project', runners_token: runners_token) }
let(:project_with_repo) { create(:project, :repository, description: 'Code and stuff') } let(:project_with_repo) { create(:project, :repository, description: 'Code and stuff') }
let(:project_variable_populated) { create(:project, namespace: namespace, path: 'builds-project2') } let(:project_variable_populated) { create(:project, namespace: namespace, path: 'builds-project2', runners_token: runners_token) }
let!(:variable1) { create(:ci_variable, project: project_variable_populated) }
let!(:variable2) { create(:ci_variable, project: project_variable_populated) }
render_views render_views
...@@ -20,6 +20,7 @@ describe 'Projects (JavaScript fixtures)', type: :controller do ...@@ -20,6 +20,7 @@ describe 'Projects (JavaScript fixtures)', type: :controller do
before do before do
project.add_maintainer(admin) project.add_maintainer(admin)
sign_in(admin) sign_in(admin)
allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon')
end end
after do after do
...@@ -70,6 +71,9 @@ describe 'Projects (JavaScript fixtures)', type: :controller do ...@@ -70,6 +71,9 @@ describe 'Projects (JavaScript fixtures)', type: :controller do
end end
it 'projects/ci_cd_settings_with_variables.html.raw' do |example| it 'projects/ci_cd_settings_with_variables.html.raw' do |example|
create(:ci_variable, project: project_variable_populated)
create(:ci_variable, project: project_variable_populated)
get :show, params: { get :show, params: {
namespace_id: project_variable_populated.namespace.to_param, namespace_id: project_variable_populated.namespace.to_param,
project_id: project_variable_populated project_id: project_variable_populated
......
...@@ -7,7 +7,6 @@ describe SnippetsController, '(JavaScript fixtures)', type: :controller do ...@@ -7,7 +7,6 @@ describe SnippetsController, '(JavaScript fixtures)', type: :controller do
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') } let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
let(:snippet) { create(:personal_snippet, title: 'snippet.md', content: '# snippet', file_name: 'snippet.md', author: admin) } let(:snippet) { create(:personal_snippet, title: 'snippet.md', content: '# snippet', file_name: 'snippet.md', author: admin) }
let!(:snippet_note) { create(:discussion_note_on_snippet, noteable: snippet, project: project, author: admin, note: '- [ ] Task List Item') }
render_views render_views
...@@ -17,6 +16,7 @@ describe SnippetsController, '(JavaScript fixtures)', type: :controller do ...@@ -17,6 +16,7 @@ describe SnippetsController, '(JavaScript fixtures)', type: :controller do
before do before do
sign_in(admin) sign_in(admin)
allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo'])
end end
after do after do
...@@ -24,6 +24,8 @@ describe SnippetsController, '(JavaScript fixtures)', type: :controller do ...@@ -24,6 +24,8 @@ describe SnippetsController, '(JavaScript fixtures)', type: :controller do
end end
it 'snippets/show.html.raw' do |example| it 'snippets/show.html.raw' do |example|
create(:discussion_note_on_snippet, noteable: snippet, project: project, author: admin, note: '- [ ] Task List Item')
get(:show, params: { id: snippet.to_param }) get(:show, params: { id: snippet.to_param })
expect(response).to be_success expect(response).to be_success
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
context 'U2F' do context 'U2F' do
include JavaScriptFixturesHelpers include JavaScriptFixturesHelpers
let(:user) { create(:user, :two_factor_via_u2f) } let(:user) { create(:user, :two_factor_via_u2f, otp_secret: 'otpsecret:coolkids') }
before(:all) do before(:all) do
clean_frontend_fixtures('u2f/') clean_frontend_fixtures('u2f/')
...@@ -33,6 +33,7 @@ context 'U2F' do ...@@ -33,6 +33,7 @@ context 'U2F' do
before do before do
sign_in(user) sign_in(user)
allow_any_instance_of(Profiles::TwoFactorAuthsController).to receive(:build_qr_code).and_return('qrcode:blackandwhitesquares')
end end
it 'u2f/register.html.raw' do |example| it 'u2f/register.html.raw' do |example|
......
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