diff options
Diffstat (limited to 'spec/models/users/project_visit_spec.rb')
-rw-r--r-- | spec/models/users/project_visit_spec.rb | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/spec/models/users/project_visit_spec.rb b/spec/models/users/project_visit_spec.rb index 38747bd6462..50e9ef02fd8 100644 --- a/spec/models/users/project_visit_spec.rb +++ b/spec/models/users/project_visit_spec.rb @@ -7,10 +7,6 @@ RSpec.describe Users::ProjectVisit, 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::ProjectVisit, feature_category: :navigation do let!(:model) { create(:project_visit, entity_id: entity.id, user_id: user.id, visited_at: base_time) } let!(:parent) { user } end + + describe '#frecent_projects' do + let_it_be(:project1) { create(:project) } + let_it_be(:project2) { create(:project) } + + before do + [ + [project1.id, 1.day.ago], + [project2.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 projects" do + expect(described_class.frecent_projects(user_id: user.id)).to eq([ + project1, + project2 + ]) + end + end end |