Commit a0719cb4 authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Use `let_it_be` for Static Site Editor tests

parent 1d1c40f9
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe Projects::StaticSiteEditorController do describe Projects::StaticSiteEditorController do
let(:project) { create(:project, :public, :repository) } let_it_be(:project) { create(:project, :public, :repository) }
let_it_be(:user) { create(:user) }
describe 'GET show' do describe 'GET show' do
let(:default_params) do let(:default_params) do
...@@ -27,8 +28,6 @@ describe Projects::StaticSiteEditorController do ...@@ -27,8 +28,6 @@ describe Projects::StaticSiteEditorController do
end end
context 'as guest' do context 'as guest' do
let(:user) { create(:user) }
before do before do
project.add_guest(user) project.add_guest(user)
sign_in(user) sign_in(user)
...@@ -42,10 +41,11 @@ describe Projects::StaticSiteEditorController do ...@@ -42,10 +41,11 @@ describe Projects::StaticSiteEditorController do
%w[developer maintainer].each do |role| %w[developer maintainer].each do |role|
context "as #{role}" do context "as #{role}" do
let(:user) { create(:user) } before_all do
project.add_role(user, role)
end
before do before do
project.add_role(user, role)
sign_in(user) sign_in(user)
get :show, params: default_params get :show, params: default_params
end end
...@@ -54,11 +54,8 @@ describe Projects::StaticSiteEditorController do ...@@ -54,11 +54,8 @@ describe Projects::StaticSiteEditorController do
expect(response).to render_template(:show) expect(response).to render_template(:show)
end end
it 'assigns a config variable' do it 'assigns a required variables' do
expect(assigns(:config)).to be_a(Gitlab::StaticSiteEditor::Config) expect(assigns(:config)).to be_a(Gitlab::StaticSiteEditor::Config)
end
it 'correctly assigns ref and path' do
expect(assigns(:ref)).to eq('master') expect(assigns(:ref)).to eq('master')
expect(assigns(:path)).to eq('README.md') expect(assigns(:path)).to eq('README.md')
end end
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe 'Static Site Editor' do describe 'Static Site Editor' do
let(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) } let_it_be(:project) { create(:project, :public, :repository) }
before do before do
project.add_maintainer(user) project.add_maintainer(user)
......
...@@ -6,7 +6,7 @@ describe 'Creation of a new branch' do ...@@ -6,7 +6,7 @@ describe 'Creation of a new branch' do
include GraphqlHelpers include GraphqlHelpers
let_it_be(:current_user) { create(:user) } let_it_be(:current_user) { create(:user) }
let(:project) { create(:project, :public, :repository) } let_it_be(:project) { create(:project, :public, :empty_repo) }
let(:input) { { project_path: project.full_path, name: new_branch, ref: ref } } let(:input) { { project_path: project.full_path, name: new_branch, ref: ref } }
let(:new_branch) { 'new_branch' } let(:new_branch) { 'new_branch' }
let(:ref) { 'master' } let(:ref) { 'master' }
...@@ -35,6 +35,7 @@ describe 'Creation of a new branch' do ...@@ -35,6 +35,7 @@ describe 'Creation of a new branch' do
end end
context 'when ref is not correct' do context 'when ref is not correct' do
let(:new_branch) { 'another_branch' }
let(:ref) { 'unknown' } let(:ref) { 'unknown' }
it_behaves_like 'a mutation that returns errors in the response', it_behaves_like 'a mutation that returns errors in the response',
......
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