2020-11-06 07:09:17 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Projects::TerraformHelper do
|
|
|
|
describe '#js_terraform_list_data' do
|
|
|
|
let_it_be(:project) { create(:project) }
|
2021-04-19 14:09:09 -04:00
|
|
|
|
2020-12-08 22:09:24 -05:00
|
|
|
let(:current_user) { project.creator }
|
2020-11-06 07:09:17 -05:00
|
|
|
|
2020-12-08 22:09:24 -05:00
|
|
|
subject { helper.js_terraform_list_data(current_user, project) }
|
2020-11-06 07:09:17 -05:00
|
|
|
|
2020-12-08 22:09:24 -05:00
|
|
|
it 'includes image path' do
|
2020-11-06 07:09:17 -05:00
|
|
|
image_path = ActionController::Base.helpers.image_path(
|
|
|
|
'illustrations/empty-state/empty-serverless-lg.svg'
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(subject[:empty_state_image]).to eq(image_path)
|
|
|
|
end
|
|
|
|
|
2020-12-08 22:09:24 -05:00
|
|
|
it 'includes project path' do
|
2020-11-06 07:09:17 -05:00
|
|
|
expect(subject[:project_path]).to eq(project.full_path)
|
|
|
|
end
|
2020-12-08 22:09:24 -05:00
|
|
|
|
|
|
|
it 'indicates the user is a terraform admin' do
|
|
|
|
expect(subject[:terraform_admin]).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when current_user is not a terraform admin' do
|
|
|
|
let(:current_user) { create(:user) }
|
|
|
|
|
|
|
|
it 'indicates the user is not an admin' do
|
|
|
|
expect(subject[:terraform_admin]).to eq(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when current_user is missing' do
|
|
|
|
let(:current_user) { nil }
|
|
|
|
|
|
|
|
it 'indicates the user is not an admin' do
|
|
|
|
expect(subject[:terraform_admin]).to be_nil
|
|
|
|
end
|
|
|
|
end
|
2020-11-06 07:09:17 -05:00
|
|
|
end
|
|
|
|
end
|