2020-09-30 23:09:55 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe NamespaceSettings::UpdateService do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:settings) { {} }
|
|
|
|
|
|
|
|
subject(:service) { described_class.new(user, group, settings) }
|
|
|
|
|
|
|
|
describe "#execute" do
|
|
|
|
context "group has no namespace_settings" do
|
2020-10-05 11:08:56 -04:00
|
|
|
before do
|
|
|
|
group.namespace_settings.destroy!
|
|
|
|
end
|
|
|
|
|
2020-09-30 23:09:55 -04:00
|
|
|
it "builds out a new namespace_settings record" do
|
|
|
|
expect do
|
|
|
|
service.execute
|
|
|
|
end.to change { NamespaceSetting.count }.by(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "group has a namespace_settings" do
|
|
|
|
before do
|
|
|
|
service.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't create a new namespace_setting record" do
|
|
|
|
expect do
|
|
|
|
service.execute
|
|
|
|
end.not_to change { NamespaceSetting.count }
|
|
|
|
end
|
|
|
|
end
|
2020-10-08 20:08:41 -04:00
|
|
|
|
|
|
|
context "updating :default_branch_name" do
|
|
|
|
let(:example_branch_name) { "example_branch_name" }
|
|
|
|
let(:settings) { { default_branch_name: example_branch_name } }
|
|
|
|
|
|
|
|
it "changes settings" do
|
|
|
|
expect { service.execute }
|
|
|
|
.to change { group.namespace_settings.default_branch_name }
|
|
|
|
.from(nil).to(example_branch_name)
|
|
|
|
end
|
|
|
|
end
|
2020-09-30 23:09:55 -04:00
|
|
|
end
|
|
|
|
end
|