Skip to content

Commit

Permalink
fix rubocops
Browse files Browse the repository at this point in the history
  • Loading branch information
fnordfish committed Sep 30, 2021
1 parent 33d7c90 commit de88449
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions spec/devise_last_seen/model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def save(validate: nil)
end
end


RSpec.describe 'Devise model extension' do
subject(:model) { Resource.new }

Expand Down Expand Up @@ -80,31 +79,31 @@ def save(validate: nil)
end
end

context "non default attribute" do
context 'with non default attribute' do
subject(:model) { ResourceNonDefaultAttribute.new }

before { Devise.setup { |c| c.last_seen_at_attribute = :last_seen_at } }

after { Devise.setup { |c| c.last_seen_at_attribute = :last_seen } }

describe '#track_last_seen!' do
it 'calls save disabling validations' do
expect(model.track_last_seen!).to eq(false)
end
it 'calls save disabling validations' do
expect(model.track_last_seen!).to eq(false)
end

it 'assigns the current time to last_seen field' do
model.track_last_seen!
it 'assigns the current time to last_seen field' do
model.track_last_seen!

expect(model.last_seen_at).to be_within(1.second).of DateTime.now
end
expect(model.last_seen_at).to be_within(1.second).of DateTime.now
end

context 'when time passed is lower than the interval' do
let(:time) { (Devise.last_seen_at_interval - 2.minutes).ago }
context 'when time passed is lower than the interval' do
let(:time) { (Devise.last_seen_at_interval - 2.minutes).ago }

it 'does not change last_seen value' do
model.last_seen_at = time
model.track_last_seen!
it 'does not change last_seen value' do
model.last_seen_at = time
model.track_last_seen!

expect(model.last_seen_at).to eq(time)
end
expect(model.last_seen_at).to eq(time)
end
end
end
Expand Down

0 comments on commit de88449

Please sign in to comment.