debian-mirror-gitlab/spec/models/blob_viewer/gitlab_ci_yml_spec.rb

39 lines
1.1 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
describe BlobViewer::GitlabCiYml do
include FakeBlobHelpers
2018-12-05 23:21:45 +05:30
include RepoHelpers
2017-09-10 17:25:29 +05:30
2020-03-13 15:44:24 +05:30
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
let(:data) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) }
let(:blob) { fake_blob(path: '.gitlab-ci.yml', data: data) }
2018-12-05 23:21:45 +05:30
let(:sha) { sample_commit.id }
2020-03-13 15:44:24 +05:30
2017-09-10 17:25:29 +05:30
subject { described_class.new(blob) }
describe '#validation_message' do
it 'calls prepare! on the viewer' do
expect(subject).to receive(:prepare!)
2019-02-15 15:39:39 +05:30
subject.validation_message(project: project, sha: sha, user: user)
2017-09-10 17:25:29 +05:30
end
context 'when the configuration is valid' do
it 'returns nil' do
2019-02-15 15:39:39 +05:30
expect(subject.validation_message(project: project, sha: sha, user: user)).to be_nil
2017-09-10 17:25:29 +05:30
end
end
context 'when the configuration is invalid' do
let(:data) { 'oof' }
it 'returns the error message' do
2019-02-15 15:39:39 +05:30
expect(subject.validation_message(project: project, sha: sha, user: user)).to eq('Invalid configuration format')
2017-09-10 17:25:29 +05:30
end
end
end
end