debian-mirror-gitlab/spec/models/integrations/shimo_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
2 KiB
Ruby
Raw Normal View History

2021-12-11 22:18:48 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::Integrations::Shimo do
describe '#fields' do
2023-01-13 00:05:48 +05:30
let(:shimo_integration) { build(:shimo_integration) }
2021-12-11 22:18:48 +05:30
it 'returns custom fields' do
expect(shimo_integration.fields.pluck(:name)).to eq(%w[external_wiki_url])
end
end
describe '#create' do
2023-01-13 00:05:48 +05:30
let_it_be(:project) { create(:project, :repository) }
2021-12-11 22:18:48 +05:30
let(:external_wiki_url) { 'https://shimo.example.com/desktop' }
let(:params) { { active: true, project: project, external_wiki_url: external_wiki_url } }
context 'with valid params' do
it 'creates the Shimo integration' do
shimo = described_class.create!(params)
expect(shimo.valid?).to be true
expect(shimo.render?).to be true
expect(shimo.external_wiki_url).to eq(external_wiki_url)
end
end
context 'with invalid params' do
it 'cannot create the Shimo integration without external_wiki_url' do
params['external_wiki_url'] = nil
expect { described_class.create!(params) }.to raise_error(ActiveRecord::RecordInvalid)
end
it 'cannot create the Shimo integration with invalid external_wiki_url' do
params['external_wiki_url'] = 'Fake Invalid URL'
expect { described_class.create!(params) }.to raise_error(ActiveRecord::RecordInvalid)
end
end
end
2022-01-26 12:08:38 +05:30
describe 'Caching has_shimo on project_settings' do
2023-01-13 00:05:48 +05:30
let_it_be(:project) { create(:project) }
2022-01-26 12:08:38 +05:30
subject { project.project_setting.has_shimo? }
it 'sets the property to true when integration is active' do
create(:shimo_integration, project: project, active: true)
is_expected.to be(true)
end
it 'sets the property to false when integration is not active' do
create(:shimo_integration, project: project, active: false)
is_expected.to be(false)
end
it 'creates a project_setting record if one was not already created' do
expect { create(:shimo_integration) }.to change(ProjectSetting, :count).by(1)
end
end
2021-12-11 22:18:48 +05:30
end