Commit 7d3bbeeb authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rs-update-rspec' into 'master'

Update rspec to 3.7

See merge request gitlab-org/gitlab-ce!19449
parents a4f37e18 b38c75b3
...@@ -333,7 +333,7 @@ group :development, :test do ...@@ -333,7 +333,7 @@ group :development, :test do
gem 'database_cleaner', '~> 1.5.0' gem 'database_cleaner', '~> 1.5.0'
gem 'factory_bot_rails', '~> 4.8.2' gem 'factory_bot_rails', '~> 4.8.2'
gem 'rspec-rails', '~> 3.6.0' gem 'rspec-rails', '~> 3.7.0'
gem 'rspec-retry', '~> 0.4.5' gem 'rspec-retry', '~> 0.4.5'
gem 'rspec_profiling', '~> 0.0.5' gem 'rspec_profiling', '~> 0.0.5'
gem 'rspec-set', '~> 0.1.3' gem 'rspec-set', '~> 0.1.3'
......
...@@ -742,36 +742,36 @@ GEM ...@@ -742,36 +742,36 @@ GEM
chunky_png chunky_png
rqrcode-rails3 (0.1.7) rqrcode-rails3 (0.1.7)
rqrcode (>= 0.4.2) rqrcode (>= 0.4.2)
rspec (3.6.0) rspec (3.7.0)
rspec-core (~> 3.6.0) rspec-core (~> 3.7.0)
rspec-expectations (~> 3.6.0) rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.6.0) rspec-mocks (~> 3.7.0)
rspec-core (3.6.0) rspec-core (3.7.1)
rspec-support (~> 3.6.0) rspec-support (~> 3.7.0)
rspec-expectations (3.6.0) rspec-expectations (3.7.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0) rspec-support (~> 3.7.0)
rspec-mocks (3.6.0) rspec-mocks (3.7.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0) rspec-support (~> 3.7.0)
rspec-parameterized (0.4.0) rspec-parameterized (0.4.0)
binding_of_caller binding_of_caller
parser parser
proc_to_ast proc_to_ast
rspec (>= 2.13, < 4) rspec (>= 2.13, < 4)
unparser unparser
rspec-rails (3.6.0) rspec-rails (3.7.2)
actionpack (>= 3.0) actionpack (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
railties (>= 3.0) railties (>= 3.0)
rspec-core (~> 3.6.0) rspec-core (~> 3.7.0)
rspec-expectations (~> 3.6.0) rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.6.0) rspec-mocks (~> 3.7.0)
rspec-support (~> 3.6.0) rspec-support (~> 3.7.0)
rspec-retry (0.4.5) rspec-retry (0.4.5)
rspec-core rspec-core
rspec-set (0.1.3) rspec-set (0.1.3)
rspec-support (3.6.0) rspec-support (3.7.1)
rspec_profiling (0.0.5) rspec_profiling (0.0.5)
activerecord activerecord
pg pg
...@@ -1141,7 +1141,7 @@ DEPENDENCIES ...@@ -1141,7 +1141,7 @@ DEPENDENCIES
rouge (~> 3.1) rouge (~> 3.1)
rqrcode-rails3 (~> 0.1.7) rqrcode-rails3 (~> 0.1.7)
rspec-parameterized rspec-parameterized
rspec-rails (~> 3.6.0) rspec-rails (~> 3.7.0)
rspec-retry (~> 0.4.5) rspec-retry (~> 0.4.5)
rspec-set (~> 0.1.3) rspec-set (~> 0.1.3)
rspec_profiling (~> 0.0.5) rspec_profiling (~> 0.0.5)
......
...@@ -18,7 +18,7 @@ describe Boards::IssuesController do ...@@ -18,7 +18,7 @@ describe Boards::IssuesController do
end end
describe 'GET index', :request_store do describe 'GET index', :request_store do
let(:johndoe) { create(:user, avatar: fixture_file_upload(File.join(Rails.root, 'spec/fixtures/dk.png'))) } let(:johndoe) { create(:user, avatar: fixture_file_upload(File.join('spec/fixtures/dk.png'))) }
context 'with invalid board id' do context 'with invalid board id' do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Groups::AvatarsController do describe Groups::AvatarsController do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:group) { create(:group, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) } let(:group) { create(:group, avatar: fixture_file_upload("spec/fixtures/dk.png", "image/png")) }
before do before do
group.add_owner(user) group.add_owner(user)
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Import::GitlabProjectsController do describe Import::GitlabProjectsController do
set(:namespace) { create(:namespace) } set(:namespace) { create(:namespace) }
set(:user) { namespace.owner } set(:user) { namespace.owner }
let(:file) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') } let(:file) { fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain') }
before do before do
sign_in(user) sign_in(user)
......
...@@ -4,7 +4,7 @@ describe Import::GoogleCodeController do ...@@ -4,7 +4,7 @@ describe Import::GoogleCodeController do
include ImportSpecHelper include ImportSpecHelper
let(:user) { create(:user) } let(:user) { create(:user) }
let(:dump_file) { fixture_file_upload(Rails.root + 'spec/fixtures/GoogleCodeProjectHosting.json', 'application/json') } let(:dump_file) { fixture_file_upload('spec/fixtures/GoogleCodeProjectHosting.json', 'application/json') }
before do before do
sign_in(user) sign_in(user)
......
require 'spec_helper' require 'spec_helper'
describe Profiles::AvatarsController do describe Profiles::AvatarsController do
let(:user) { create(:user, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png")) } let(:user) { create(:user, avatar: fixture_file_upload("spec/fixtures/dk.png")) }
before do before do
sign_in(user) sign_in(user)
......
require 'spec_helper' require 'spec_helper'
describe Projects::AvatarsController do describe Projects::AvatarsController do
let(:project) { create(:project, :repository, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) } let(:project) { create(:project, :repository, avatar: fixture_file_upload("spec/fixtures/dk.png", "image/png")) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
...@@ -6,8 +6,8 @@ describe ProjectsController do ...@@ -6,8 +6,8 @@ describe ProjectsController do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:public_project) { create(:project, :public) } let(:public_project) { create(:project, :public) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') } let(:jpg) { fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg') }
let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') } let(:txt) { fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain') }
describe 'GET new' do describe 'GET new' do
context 'with an authenticated user' do context 'with an authenticated user' do
......
...@@ -6,13 +6,13 @@ shared_examples 'content not cached without revalidation' do ...@@ -6,13 +6,13 @@ shared_examples 'content not cached without revalidation' do
end end
describe UploadsController do describe UploadsController do
let!(:user) { create(:user, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) } let!(:user) { create(:user, avatar: fixture_file_upload("spec/fixtures/dk.png", "image/png")) }
describe 'POST create' do describe 'POST create' do
let(:model) { 'personal_snippet' } let(:model) { 'personal_snippet' }
let(:snippet) { create(:personal_snippet, :public) } let(:snippet) { create(:personal_snippet, :public) }
let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') } let(:jpg) { fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg') }
let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') } let(:txt) { fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain') }
context 'when a user does not have permissions to upload a file' do context 'when a user does not have permissions to upload a file' do
it "returns 401 when the user is not logged in" do it "returns 401 when the user is not logged in" do
...@@ -205,7 +205,7 @@ describe UploadsController do ...@@ -205,7 +205,7 @@ describe UploadsController do
end end
context "when viewing a project avatar" do context "when viewing a project avatar" do
let!(:project) { create(:project, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) } let!(:project) { create(:project, avatar: fixture_file_upload("spec/fixtures/dk.png", "image/png")) }
context "when the project is public" do context "when the project is public" do
before do before do
...@@ -314,7 +314,7 @@ describe UploadsController do ...@@ -314,7 +314,7 @@ describe UploadsController do
end end
context "when viewing a group avatar" do context "when viewing a group avatar" do
let!(:group) { create(:group, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) } let!(:group) { create(:group, avatar: fixture_file_upload("spec/fixtures/dk.png", "image/png")) }
context "when the group is public" do context "when the group is public" do
context "when not signed in" do context "when not signed in" do
...@@ -521,7 +521,7 @@ describe UploadsController do ...@@ -521,7 +521,7 @@ describe UploadsController do
context 'Appearance' do context 'Appearance' do
context 'when viewing a custom header logo' do context 'when viewing a custom header logo' do
let!(:appearance) { create :appearance, header_logo: fixture_file_upload(Rails.root.join('spec/fixtures/dk.png'), 'image/png') } let!(:appearance) { create :appearance, header_logo: fixture_file_upload('spec/fixtures/dk.png', 'image/png') }
context 'when not signed in' do context 'when not signed in' do
it 'responds with status 200' do it 'responds with status 200' do
...@@ -541,7 +541,7 @@ describe UploadsController do ...@@ -541,7 +541,7 @@ describe UploadsController do
end end
context 'when viewing a custom logo' do context 'when viewing a custom logo' do
let!(:appearance) { create :appearance, logo: fixture_file_upload(Rails.root.join('spec/fixtures/dk.png'), 'image/png') } let!(:appearance) { create :appearance, logo: fixture_file_upload('spec/fixtures/dk.png', 'image/png') }
context 'when not signed in' do context 'when not signed in' do
it 'responds with status 200' do it 'responds with status 200' do
......
...@@ -7,7 +7,7 @@ FactoryBot.define do ...@@ -7,7 +7,7 @@ FactoryBot.define do
end end
trait :with_file do trait :with_file do
file { fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "`/png") } file { fixture_file_upload("spec/fixtures/dk.png", "`/png") }
end end
# The uniqueness constraint means we can't use the correct OID for all LFS # The uniqueness constraint means we can't use the correct OID for all LFS
......
...@@ -130,11 +130,11 @@ FactoryBot.define do ...@@ -130,11 +130,11 @@ FactoryBot.define do
end end
trait :with_attachment do trait :with_attachment do
attachment { fixture_file_upload(Rails.root.join( "spec/fixtures/dk.png"), "image/png") } attachment { fixture_file_upload("spec/fixtures/dk.png", "image/png") }
end end
trait :with_svg_attachment do trait :with_svg_attachment do
attachment { fixture_file_upload(Rails.root.join("spec/fixtures/unsanitized.svg"), "image/svg+xml") } attachment { fixture_file_upload("spec/fixtures/unsanitized.svg", "image/svg+xml") }
end end
transient do transient do
......
...@@ -47,7 +47,7 @@ describe 'Commits' do ...@@ -47,7 +47,7 @@ describe 'Commits' do
context 'commit status is Ci Build' do context 'commit status is Ci Build' do
let!(:build) { create(:ci_build, pipeline: pipeline) } let!(:build) { create(:ci_build, pipeline: pipeline) }
let(:artifacts_file) { fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') } let(:artifacts_file) { fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') }
context 'when logged as developer' do context 'when logged as developer' do
before do before do
......
...@@ -23,8 +23,8 @@ describe 'Merge request < User sees mini pipeline graph', :js do ...@@ -23,8 +23,8 @@ describe 'Merge request < User sees mini pipeline graph', :js do
end end
context 'as json' do context 'as json' do
let(:artifacts_file1) { fixture_file_upload(Rails.root.join('spec/fixtures/banana_sample.gif'), 'image/gif') } let(:artifacts_file1) { fixture_file_upload(File.join('spec/fixtures/banana_sample.gif'), 'image/gif') }
let(:artifacts_file2) { fixture_file_upload(Rails.root.join('spec/fixtures/dk.png'), 'image/png') } let(:artifacts_file2) { fixture_file_upload(File.join('spec/fixtures/dk.png'), 'image/png') }
before do before do
create(:ci_build, :success, :trace_artifact, pipeline: pipeline, legacy_artifacts_file: artifacts_file1) create(:ci_build, :success, :trace_artifact, pipeline: pipeline, legacy_artifacts_file: artifacts_file1)
......
...@@ -88,8 +88,7 @@ describe 'Project Jobs Permissions' do ...@@ -88,8 +88,7 @@ describe 'Project Jobs Permissions' do
describe 'artifacts page' do describe 'artifacts page' do
context 'when recent job has artifacts available' do context 'when recent job has artifacts available' do
before do before do
artifacts = Rails.root.join('spec/fixtures/ci_build_artifacts.zip') archive = fixture_file_upload('spec/fixtures/ci_build_artifacts.zip')
archive = fixture_file_upload(artifacts, 'application/zip')
job.update_attributes(legacy_artifacts_file: archive) job.update_attributes(legacy_artifacts_file: archive)
end end
......
...@@ -11,7 +11,7 @@ feature 'Jobs', :clean_gitlab_redis_shared_state do ...@@ -11,7 +11,7 @@ feature 'Jobs', :clean_gitlab_redis_shared_state do
let(:job2) { create(:ci_build) } let(:job2) { create(:ci_build) }
let(:artifacts_file) do let(:artifacts_file) do
fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif')
end end
before do before do
......
...@@ -314,8 +314,8 @@ feature 'Pages' do ...@@ -314,8 +314,8 @@ feature 'Pages' do
project: project, project: project,
pipeline: pipeline, pipeline: pipeline,
ref: 'HEAD', ref: 'HEAD',
legacy_artifacts_file: fixture_file_upload(Rails.root.join('spec/fixtures/pages.zip')), legacy_artifacts_file: fixture_file_upload(File.join('spec/fixtures/pages.zip')),
legacy_artifacts_metadata: fixture_file_upload(Rails.root.join('spec/fixtures/pages.zip.meta')) legacy_artifacts_metadata: fixture_file_upload(File.join('spec/fixtures/pages.zip.meta'))
) )
end end
......
...@@ -47,9 +47,7 @@ describe EmailsHelper do ...@@ -47,9 +47,7 @@ describe EmailsHelper do
describe '#header_logo' do describe '#header_logo' do
context 'there is a brand item with a logo' do context 'there is a brand item with a logo' do
it 'returns the brand header logo' do it 'returns the brand header logo' do
appearance = create :appearance, header_logo: fixture_file_upload( appearance = create :appearance, header_logo: fixture_file_upload('spec/fixtures/dk.png')
Rails.root.join('spec/fixtures/dk.png')
)
expect(header_logo).to eq( expect(header_logo).to eq(
%{<img style="height: 50px" src="/uploads/-/system/appearance/header_logo/#{appearance.id}/dk.png" alt="Dk" />} %{<img style="height: 50px" src="/uploads/-/system/appearance/header_logo/#{appearance.id}/dk.png" alt="Dk" />}
......
...@@ -4,9 +4,9 @@ describe GroupsHelper do ...@@ -4,9 +4,9 @@ describe GroupsHelper do
include ApplicationHelper include ApplicationHelper
describe 'group_icon' do describe 'group_icon' do
avatar_file_path = File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
it 'returns an url for the avatar' do it 'returns an url for the avatar' do
avatar_file_path = File.join('spec', 'fixtures', 'banana_sample.gif')
group = create(:group) group = create(:group)
group.avatar = fixture_file_upload(avatar_file_path) group.avatar = fixture_file_upload(avatar_file_path)
group.save! group.save!
...@@ -17,9 +17,9 @@ describe GroupsHelper do ...@@ -17,9 +17,9 @@ describe GroupsHelper do
end end
describe 'group_icon_url' do describe 'group_icon_url' do
avatar_file_path = File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
it 'returns an url for the avatar' do it 'returns an url for the avatar' do
avatar_file_path = File.join('spec', 'fixtures', 'banana_sample.gif')
group = create(:group) group = create(:group)
group.avatar = fixture_file_upload(avatar_file_path) group.avatar = fixture_file_upload(avatar_file_path)
group.save! group.save!
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::ImportExport::AvatarSaver do describe Gitlab::ImportExport::AvatarSaver do
let(:shared) { project.import_export_shared } let(:shared) { project.import_export_shared }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:project_with_avatar) { create(:project, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) } let(:project_with_avatar) { create(:project, avatar: fixture_file_upload("spec/fixtures/dk.png", "image/png")) }
let(:project) { create(:project) } let(:project) { create(:project) }
before do before do
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::ImportExport::UploadsSaver do describe Gitlab::ImportExport::UploadsSaver do
describe 'bundle a project Git repo' do describe 'bundle a project Git repo' do
let(:export_path) { "#{Dir.tmpdir}/uploads_saver_spec" } let(:export_path) { "#{Dir.tmpdir}/uploads_saver_spec" }
let(:file) { fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') } let(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') }
let(:shared) { project.import_export_shared } let(:shared) { project.import_export_shared }
before do before do
......
...@@ -76,12 +76,12 @@ describe Ci::JobArtifact do ...@@ -76,12 +76,12 @@ describe Ci::JobArtifact do
context 'updating the artifact file' do context 'updating the artifact file' do
it 'updates the artifact size' do it 'updates the artifact size' do
artifact.update!(file: fixture_file_upload(File.join(Rails.root, 'spec/fixtures/dk.png'))) artifact.update!(file: fixture_file_upload('spec/fixtures/dk.png'))
expect(artifact.size).to eq(1062) expect(artifact.size).to eq(1062)
end end
it 'updates the project statistics' do it 'updates the project statistics' do
expect { artifact.update!(file: fixture_file_upload(File.join(Rails.root, 'spec/fixtures/dk.png'))) } expect { artifact.update!(file: fixture_file_upload('spec/fixtures/dk.png')) }
.to change { artifact.project.statistics.reload.build_artifacts_size } .to change { artifact.project.statistics.reload.build_artifacts_size }
.by(1062 - 106365) .by(1062 - 106365)
end end
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe API::ProjectImport do describe API::ProjectImport do
let(:export_path) { "#{Dir.tmpdir}/project_export_spec" } let(:export_path) { "#{Dir.tmpdir}/project_export_spec" }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:file) { File.join(Rails.root, 'spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') } let(:file) { File.join('spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') }
let(:namespace) { create(:group) } let(:namespace) { create(:group) }
before do before do
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path) allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
......
...@@ -518,7 +518,7 @@ describe API::Projects do ...@@ -518,7 +518,7 @@ describe API::Projects do
end end
it 'uploads avatar for project a project' do it 'uploads avatar for project a project' do
project = attributes_for(:project, avatar: fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif')) project = attributes_for(:project, avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif'))
post api('/projects', user), project post api('/projects', user), project
...@@ -777,7 +777,7 @@ describe API::Projects do ...@@ -777,7 +777,7 @@ describe API::Projects do
end end
it "uploads the file and returns its info" do it "uploads the file and returns its info" do
post api("/projects/#{project.id}/uploads", user), file: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png") post api("/projects/#{project.id}/uploads", user), file: fixture_file_upload("spec/fixtures/dk.png", "image/png")
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(201)
expect(json_response['alt']).to eq("dk") expect(json_response['alt']).to eq("dk")
......
...@@ -1085,8 +1085,8 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -1085,8 +1085,8 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
let(:jwt_token) { JWT.encode({ 'iss' => 'gitlab-workhorse' }, Gitlab::Workhorse.secret, 'HS256') } let(:jwt_token) { JWT.encode({ 'iss' => 'gitlab-workhorse' }, Gitlab::Workhorse.secret, 'HS256') }
let(:headers) { { 'GitLab-Workhorse' => '1.0', Gitlab::Workhorse::INTERNAL_API_REQUEST_HEADER => jwt_token } } let(:headers) { { 'GitLab-Workhorse' => '1.0', Gitlab::Workhorse::INTERNAL_API_REQUEST_HEADER => jwt_token } }
let(:headers_with_token) { headers.merge(API::Helpers::Runner::JOB_TOKEN_HEADER => job.token) } let(:headers_with_token) { headers.merge(API::Helpers::Runner::JOB_TOKEN_HEADER => job.token) }
let(:file_upload) { fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') } let(:file_upload) { fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') }
let(:file_upload2) { fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', 'image/gif') } let(:file_upload2) { fixture_file_upload('spec/fixtures/dk.png', 'image/gif') }
before do before do
stub_artifacts_object_storage stub_artifacts_object_storage
......
...@@ -512,7 +512,7 @@ describe API::Users do ...@@ -512,7 +512,7 @@ describe API::Users do
end end
it 'updates user with avatar' do it 'updates user with avatar' do
put api("/users/#{user.id}", admin), { avatar: fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') } put api("/users/#{user.id}", admin), { avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') }
user.reload user.reload
......
...@@ -61,7 +61,7 @@ describe 'OpenID Connect requests' do ...@@ -61,7 +61,7 @@ describe 'OpenID Connect requests' do
email: private_email.email, email: private_email.email,
public_email: public_email.email, public_email: public_email.email,
website_url: 'https://example.com', website_url: 'https://example.com',
avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png") avatar: fixture_file_upload('spec/fixtures/dk.png')
) )
end end
......
...@@ -8,7 +8,7 @@ describe Projects::ForkService do ...@@ -8,7 +8,7 @@ describe Projects::ForkService do
before do before do
@from_user = create(:user) @from_user = create(:user)
@from_namespace = @from_user.namespace @from_namespace = @from_user.namespace
avatar = fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png") avatar = fixture_file_upload("spec/fixtures/dk.png", "image/png")
@from_project = create(:project, @from_project = create(:project,
:repository, :repository,
creator_id: @from_user.id, creator_id: @from_user.id,
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::GitlabProjectsImportService do describe Projects::GitlabProjectsImportService do
set(:namespace) { create(:namespace) } set(:namespace) { create(:namespace) }
let(:path) { 'test-path' } let(:path) { 'test-path' }
let(:file) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') } let(:file) { fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain') }
let(:overwrite) { false } let(:overwrite) { false }
let(:import_params) { { namespace_id: namespace.id, path: path, file: file, overwrite: overwrite } } let(:import_params) { { namespace_id: namespace.id, path: path, file: file, overwrite: overwrite } }
subject { described_class.new(namespace.owner, import_params) } subject { described_class.new(namespace.owner, import_params) }
......
...@@ -4,7 +4,7 @@ describe Projects::ParticipantsService do ...@@ -4,7 +4,7 @@ describe Projects::ParticipantsService do
describe '#groups' do describe '#groups' do
describe 'avatar_url' do describe 'avatar_url' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
let(:group) { create(:group, avatar: fixture_file_upload(Rails.root + 'spec/fixtures/dk.png')) } let(:group) { create(:group, avatar: fixture_file_upload('spec/fixtures/dk.png')) }
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:group_member) { create(:group_member, group: group, user: user) } let!(:group_member) { create(:group_member, group: group, user: user) }
......
...@@ -4,13 +4,13 @@ describe Projects::UpdatePagesService do ...@@ -4,13 +4,13 @@ describe Projects::UpdatePagesService do
set(:project) { create(:project, :repository) } set(:project) { create(:project, :repository) }
set(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) } set(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) }
set(:build) { create(:ci_build, pipeline: pipeline, ref: 'HEAD') } set(:build) { create(:ci_build, pipeline: pipeline, ref: 'HEAD') }
let(:invalid_file) { fixture_file_upload(Rails.root + 'spec/fixtures/dk.png') } let(:invalid_file) { fixture_file_upload('spec/fixtures/dk.png') }
let(:extension) { 'zip' } let(:extension) { 'zip' }
let(:file) { fixture_file_upload(Rails.root + "spec/fixtures/pages.#{extension}") } let(:file) { fixture_file_upload("spec/fixtures/pages.#{extension}") }
let(:empty_file) { fixture_file_upload(Rails.root + "spec/fixtures/pages_empty.#{extension}") } let(:empty_file) { fixture_file_upload("spec/fixtures/pages_empty.#{extension}") }
let(:metadata) do let(:metadata) do
filename = Rails.root + "spec/fixtures/pages.#{extension}.meta" filename = "spec/fixtures/pages.#{extension}.meta"
fixture_file_upload(filename) if File.exist?(filename) fixture_file_upload(filename) if File.exist?(filename)
end end
...@@ -196,8 +196,8 @@ describe Projects::UpdatePagesService do ...@@ -196,8 +196,8 @@ describe Projects::UpdatePagesService do
let(:metadata) { spy('metadata') } let(:metadata) { spy('metadata') }
before do before do
file = fixture_file_upload(Rails.root + 'spec/fixtures/pages.zip') file = fixture_file_upload('spec/fixtures/pages.zip')
metafile = fixture_file_upload(Rails.root + 'spec/fixtures/pages.zip.meta') metafile = fixture_file_upload('spec/fixtures/pages.zip.meta')
build.update_attributes(legacy_artifacts_file: file) build.update_attributes(legacy_artifacts_file: file)
build.update_attributes(legacy_artifacts_metadata: metafile) build.update_attributes(legacy_artifacts_metadata: metafile)
......
...@@ -9,7 +9,7 @@ describe UploadService do ...@@ -9,7 +9,7 @@ describe UploadService do
context 'for valid gif file' do context 'for valid gif file' do
before do before do
gif = fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') gif = fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif')
@link_to_file = upload_file(@project, gif) @link_to_file = upload_file(@project, gif)
end end
...@@ -21,7 +21,7 @@ describe UploadService do ...@@ -21,7 +21,7 @@ describe UploadService do
context 'for valid png file' do context 'for valid png file' do
before do before do
png = fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', png = fixture_file_upload('spec/fixtures/dk.png',
'image/png') 'image/png')
@link_to_file = upload_file(@project, png) @link_to_file = upload_file(@project, png)
end end
...@@ -34,7 +34,7 @@ describe UploadService do ...@@ -34,7 +34,7 @@ describe UploadService do
context 'for valid jpg file' do context 'for valid jpg file' do
before do before do
jpg = fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') jpg = fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg')
@link_to_file = upload_file(@project, jpg) @link_to_file = upload_file(@project, jpg)
end end
...@@ -46,7 +46,7 @@ describe UploadService do ...@@ -46,7 +46,7 @@ describe UploadService do
context 'for txt file' do context 'for txt file' do
before do before do
txt = fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') txt = fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain')
@link_to_file = upload_file(@project, txt) @link_to_file = upload_file(@project, txt)
end end
...@@ -58,7 +58,7 @@ describe UploadService do ...@@ -58,7 +58,7 @@ describe UploadService do
context 'for too large a file' do context 'for too large a file' do
before do before do
txt = fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') txt = fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain')
allow(txt).to receive(:size) { 1000.megabytes.to_i } allow(txt).to receive(:size) { 1000.megabytes.to_i }
@link_to_file = upload_file(@project, txt) @link_to_file = upload_file(@project, txt)
end end
......
...@@ -9,4 +9,6 @@ RSpec.configure do |config| ...@@ -9,4 +9,6 @@ RSpec.configure do |config|
config.include StubConfiguration config.include StubConfiguration
config.include StubObjectStorage config.include StubObjectStorage
config.include StubENV config.include StubENV
config.fixture_path = Rails.root if defined?(Rails)
end end
shared_examples 'handle uploads' do shared_examples 'handle uploads' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') } let(:jpg) { fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg') }
let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') } let(:txt) { fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain') }
let(:secret) { FileUploader.generate_secret } let(:secret) { FileUploader.generate_secret }
let(:uploader_class) { FileUploader } let(:uploader_class) { FileUploader }
......
...@@ -26,7 +26,7 @@ describe AttachmentUploader do ...@@ -26,7 +26,7 @@ describe AttachmentUploader do
describe "#migrate!" do describe "#migrate!" do
before do before do
uploader.store!(fixture_file_upload(Rails.root.join('spec/fixtures/doc_sample.txt'))) uploader.store!(fixture_file_upload(File.join('spec/fixtures/doc_sample.txt')))
stub_uploads_object_storage stub_uploads_object_storage
end end
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe FileMover do describe FileMover do
let(:filename) { 'banana_sample.gif' } let(:filename) { 'banana_sample.gif' }
let(:file) { fixture_file_upload(Rails.root.join('spec', 'fixtures', filename)) } let(:file) { fixture_file_upload(File.join('spec', 'fixtures', filename)) }
let(:temp_file_path) { File.join('uploads/-/system/temp', 'secret55', filename) } let(:temp_file_path) { File.join('uploads/-/system/temp', 'secret55', filename) }
let(:temp_description) do let(:temp_description) do
......
...@@ -89,7 +89,7 @@ describe FileUploader do ...@@ -89,7 +89,7 @@ describe FileUploader do
describe "#migrate!" do describe "#migrate!" do
before do before do
uploader.store!(fixture_file_upload(Rails.root.join('spec/fixtures/dk.png'))) uploader.store!(fixture_file_upload('spec/fixtures/dk.png'))
stub_uploads_object_storage stub_uploads_object_storage
end end
......
...@@ -62,7 +62,7 @@ describe GitlabUploader do ...@@ -62,7 +62,7 @@ describe GitlabUploader do
expect(FileUtils).to receive(:mv).with(anything, /^#{subject.work_dir}/).and_call_original expect(FileUtils).to receive(:mv).with(anything, /^#{subject.work_dir}/).and_call_original
expect(FileUtils).to receive(:mv).with(/^#{subject.work_dir}/, /#{subject.cache_dir}/).and_call_original expect(FileUtils).to receive(:mv).with(/^#{subject.work_dir}/, /#{subject.cache_dir}/).and_call_original
fixture = Rails.root.join('spec', 'fixtures', 'rails_sample.jpg') fixture = File.join('spec', 'fixtures', 'rails_sample.jpg')
subject.cache!(fixture_file_upload(fixture)) subject.cache!(fixture_file_upload(fixture))
expect(subject.file.path).to match(/#{subject.cache_dir}/) expect(subject.file.path).to match(/#{subject.cache_dir}/)
......
...@@ -29,8 +29,7 @@ describe JobArtifactUploader do ...@@ -29,8 +29,7 @@ describe JobArtifactUploader do
context 'when trace is stored in File storage' do context 'when trace is stored in File storage' do
context 'when file exists' do context 'when file exists' do
let(:file) do let(:file) do
fixture_file_upload( fixture_file_upload('spec/fixtures/trace/sample_trace', 'text/plain')
Rails.root.join('spec/fixtures/trace/sample_trace'), 'text/plain')
end end
before do before do
...@@ -63,8 +62,7 @@ describe JobArtifactUploader do ...@@ -63,8 +62,7 @@ describe JobArtifactUploader do
context 'file is stored in valid local_path' do context 'file is stored in valid local_path' do
let(:file) do let(:file) do
fixture_file_upload( fixture_file_upload('spec/fixtures/ci_build_artifacts.zip', 'application/zip')
Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip')
end end
before do before do
...@@ -81,7 +79,7 @@ describe JobArtifactUploader do ...@@ -81,7 +79,7 @@ describe JobArtifactUploader do
describe "#migrate!" do describe "#migrate!" do
before do before do
uploader.store!(fixture_file_upload(Rails.root.join('spec/fixtures/trace/sample_trace'))) uploader.store!(fixture_file_upload('spec/fixtures/trace/sample_trace'))
stub_artifacts_object_storage stub_artifacts_object_storage
end end
......
...@@ -44,8 +44,7 @@ describe LegacyArtifactUploader do ...@@ -44,8 +44,7 @@ describe LegacyArtifactUploader do
context 'file is stored in valid path' do context 'file is stored in valid path' do
let(:file) do let(:file) do
fixture_file_upload( fixture_file_upload('spec/fixtures/ci_build_artifacts.zip', 'application/zip')
Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip')
end end
before do before do
......
...@@ -28,7 +28,7 @@ describe NamespaceFileUploader do ...@@ -28,7 +28,7 @@ describe NamespaceFileUploader do
describe "#migrate!" do describe "#migrate!" do
before do before do
uploader.store!(fixture_file_upload(Rails.root.join('spec/fixtures/doc_sample.txt'))) uploader.store!(fixture_file_upload(File.join('spec/fixtures/doc_sample.txt')))
stub_uploads_object_storage stub_uploads_object_storage
end end
......
...@@ -571,7 +571,7 @@ describe ObjectStorage do ...@@ -571,7 +571,7 @@ describe ObjectStorage do
context 'when local file is used' do context 'when local file is used' do
context 'when valid file is used' do context 'when valid file is used' do
let(:uploaded_file) do let(:uploaded_file) do
fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg')
end end
it "properly caches the file" do it "properly caches the file" do
......
...@@ -45,7 +45,7 @@ describe PersonalFileUploader do ...@@ -45,7 +45,7 @@ describe PersonalFileUploader do
describe "#migrate!" do describe "#migrate!" do
before do before do
uploader.store!(fixture_file_upload(Rails.root.join('spec/fixtures/doc_sample.txt'))) uploader.store!(fixture_file_upload('spec/fixtures/doc_sample.txt'))
stub_uploads_object_storage stub_uploads_object_storage
end end
......
...@@ -16,7 +16,7 @@ describe RecordsUploads do ...@@ -16,7 +16,7 @@ describe RecordsUploads do
end end
def upload_fixture(filename) def upload_fixture(filename)
fixture_file_upload(Rails.root.join('spec', 'fixtures', filename)) fixture_file_upload(File.join('spec', 'fixtures', filename))
end end
describe 'callbacks' do describe 'callbacks' do
......
...@@ -12,7 +12,7 @@ describe UploaderHelper do ...@@ -12,7 +12,7 @@ describe UploaderHelper do
end end
def upload_fixture(filename) def upload_fixture(filename)
fixture_file_upload(Rails.root.join('spec', 'fixtures', filename)) fixture_file_upload(File.join('spec', 'fixtures', filename))
end end
describe '#image_or_video?' do describe '#image_or_video?' 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