diff options
Diffstat (limited to 'spec/models/users/group_visit_spec.rb')
-rw-r--r-- | spec/models/users/group_visit_spec.rb | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/spec/models/users/group_visit_spec.rb b/spec/models/users/group_visit_spec.rb index 63c4631ad7d..241cb537fad 100644 --- a/spec/models/users/group_visit_spec.rb +++ b/spec/models/users/group_visit_spec.rb @@ -7,10 +7,6 @@ RSpec.describe Users::GroupVisit, feature_category: :navigation do let_it_be(:user) { create(:user) } let_it_be(:base_time) { DateTime.now } - before do - described_class.create!(entity_id: entity.id, user_id: user.id, visited_at: base_time) - end - it_behaves_like 'namespace visits model' it_behaves_like 'cleanup by a loose foreign key' do @@ -22,4 +18,25 @@ RSpec.describe Users::GroupVisit, feature_category: :navigation do let!(:model) { create(:group_visit, entity_id: entity.id, user_id: user.id, visited_at: base_time) } let!(:parent) { user } end + + describe '#frecent_groups' do + let_it_be(:group1) { create(:group) } + let_it_be(:group2) { create(:group) } + + before do + [ + [group1.id, 1.day.ago], + [group2.id, 2.days.ago] + ].each do |id, datetime| + described_class.create!(entity_id: id, user_id: user.id, visited_at: datetime) + end + end + + it "returns the associated frecently visited groups" do + expect(described_class.frecent_groups(user_id: user.id)).to eq([ + group1, + group2 + ]) + end + end end |