Does not update remember_created_at when in a Geo secondary node

parent 1df30f45
...@@ -52,5 +52,15 @@ module EE ...@@ -52,5 +52,15 @@ module EE
def admin_or_auditor? def admin_or_auditor?
admin? || auditor? admin? || auditor?
end end
def remember_me!
return if ::Gitlab::Geo.secondary?
super
end
def forget_me!
return if ::Gitlab::Geo.secondary?
super
end
end end
end end
...@@ -1938,4 +1938,36 @@ describe User, models: true do ...@@ -1938,4 +1938,36 @@ describe User, models: true do
expect(user.preferred_language).to eq('en') expect(user.preferred_language).to eq('en')
end end
end end
describe '#forget_me!' do
subject { create(:user, remember_created_at: Time.now) }
it 'clears remember_created_at' do
subject.forget_me!
expect(subject.reload.remember_created_at).to be_nil
end
it 'does not clear remember_created_at when in a Geo secondary node' do
allow(Gitlab::Geo).to receive(:secondary?) { true }
expect { subject.forget_me! }.not_to change(subject, :remember_created_at)
end
end
describe '#remember_me!' do
subject { create(:user, remember_created_at: nil) }
it 'updates remember_created_at' do
subject.remember_me!
expect(subject.reload.remember_created_at).not_to be_nil
end
it 'does not update remember_created_at when in a Geo secondary node' do
allow(Gitlab::Geo).to receive(:secondary?) { true }
expect { subject.remember_me! }.not_to change(subject, :remember_created_at)
end
end
end end
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