diff options
Diffstat (limited to 'spec/lib/gitlab/ci/external_files/external_file_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/external_files/external_file_spec.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/spec/lib/gitlab/ci/external_files/external_file_spec.rb b/spec/lib/gitlab/ci/external_files/external_file_spec.rb index 33e5e0b3b77..b2aeb0ac67a 100644 --- a/spec/lib/gitlab/ci/external_files/external_file_spec.rb +++ b/spec/lib/gitlab/ci/external_files/external_file_spec.rb @@ -1,12 +1,17 @@ require 'rails_helper' describe Gitlab::Ci::ExternalFiles::ExternalFile do - let(:external_file) { described_class.new(value) } + let(:project) { create(:project, :repository) } + let(:external_file) { described_class.new(value, project) } describe "#valid?" do context 'when is a valid remote url' do let(:value) { 'https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' } + before do + allow_any_instance_of(described_class).to receive(:local_file_content).and_return("image: 'ruby2:2'") + end + it 'should return true' do expect(external_file.valid?).to be_truthy end @@ -54,8 +59,7 @@ describe Gitlab::Ci::ExternalFiles::ExternalFile do let(:value) { '/vendor/gitlab-ci-yml/non-existent-file.yml' } before do - allow(File).to receive(:exists?).and_return(true) - allow(File).to receive(:read).and_return(external_file_content) + allow_any_instance_of(described_class).to receive(:local_file_content).and_return(external_file_content) end it 'should return the content of the file' do |