Commit 207f0a1b authored by Stan Hu's avatar Stan Hu

Make RemoteMirror's only_protected_branches default value consistent

From https://gitlab.com/gitlab-org/gitlab-ce/issues/53515, we see the
backend appears to have inconsistent default values for this column:

* DB schema: false by default
* UI checkbox: false by default
* `RemoteMirror` model: true by default

This leads to unintended behavior where the boolean is activated if the
UI doesn't pass in a value for the checkbox.
parent 75eb0416
...@@ -15,8 +15,6 @@ class RemoteMirror < ActiveRecord::Base ...@@ -15,8 +15,6 @@ class RemoteMirror < ActiveRecord::Base
insecure_mode: true, insecure_mode: true,
algorithm: 'aes-256-cbc' algorithm: 'aes-256-cbc'
default_value_for :only_protected_branches, true
belongs_to :project, inverse_of: :remote_mirrors belongs_to :project, inverse_of: :remote_mirrors
validates :url, presence: true, url: { protocols: %w(ssh git http https), allow_blank: true, enforce_user: true } validates :url, presence: true, url: { protocols: %w(ssh git http https), allow_blank: true, enforce_user: true }
......
...@@ -174,7 +174,15 @@ describe RemoteMirror do ...@@ -174,7 +174,15 @@ describe RemoteMirror do
end end
context 'with remote mirroring enabled' do context 'with remote mirroring enabled' do
it 'defaults to disabling only protected branches' do
expect(remote_mirror.only_protected_branches?).to be_falsey
end
context 'with only protected branches enabled' do context 'with only protected branches enabled' do
before do
remote_mirror.only_protected_branches = true
end
context 'when it did not update in the last minute' do context 'when it did not update in the last minute' do
it 'schedules a RepositoryUpdateRemoteMirrorWorker to run now' do it 'schedules a RepositoryUpdateRemoteMirrorWorker to run now' do
expect(RepositoryUpdateRemoteMirrorWorker).to receive(:perform_async).with(remote_mirror.id, Time.now) expect(RepositoryUpdateRemoteMirrorWorker).to receive(:perform_async).with(remote_mirror.id, Time.now)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment