gitlab-org--gitlab-foss/spec/models/blob_viewer/gitlab_ci_yml_spec.rb

37 lines
1 KiB
Ruby
Raw Normal View History

2017-05-08 19:50:23 -04:00
require 'spec_helper'
describe BlobViewer::GitlabCiYml do
2017-05-08 19:50:23 -04:00
include FakeBlobHelpers
include RepoHelpers
2017-05-08 19:50:23 -04:00
set(:project) { create(:project, :repository) }
set(:user) { create(:user) }
2017-05-08 19:50:23 -04:00
let(:data) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) }
let(:blob) { fake_blob(path: '.gitlab-ci.yml', data: data) }
let(:sha) { sample_commit.id }
2017-05-08 19:50:23 -04:00
subject { described_class.new(blob) }
describe '#validation_message' do
it 'calls prepare! on the viewer' do
expect(subject).to receive(:prepare!)
subject.validation_message(project: project, sha: sha, user: user)
2017-05-08 19:50:23 -04:00
end
context 'when the configuration is valid' do
it 'returns nil' do
expect(subject.validation_message(project: project, sha: sha, user: user)).to be_nil
2017-05-08 19:50:23 -04:00
end
end
context 'when the configuration is invalid' do
let(:data) { 'oof' }
it 'returns the error message' do
expect(subject.validation_message(project: project, sha: sha, user: user)).to eq('Invalid configuration format')
2017-05-08 19:50:23 -04:00
end
end
end
end