Skip to content

Commit

Permalink
add test for new module indicator on in progress modules
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-coggin committed Dec 5, 2023
1 parent 375318f commit 5855be9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/content_changes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ContentChanges
def new_modules?
return false if previous_visit.nil?

previous_visit && new_modules.any?
new_modules.any?
end

# @param mod [Training::Module]
Expand Down
22 changes: 22 additions & 0 deletions spec/services/content_changes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,28 @@
it 'returns true' do
expect(changes.new_module?(alpha)).to be true
end

context 'with a module in progress' do
include_context 'with progress'
before do
create :visit,
id: 3,
visitor_token: '321',
user_id: user.id,
started_at: 5.days.ago

create :visit,
id: 4,
visitor_token: '654',
user_id: user.id,
started_at: 5.days.ago
start_module(alpha)
end

it 'returns false' do
expect(changes.new_module?(alpha)).to be false
end
end
end
end
end

0 comments on commit 5855be9

Please sign in to comment.