Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions spec/services/fetch_reports_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

RSpec.describe(DiscourseRewind::FetchReports) do
describe ".call" do
subject(:result) { described_class.call(**dependencies) }

fab!(:current_user) { Fabricate(:user) }

let(:guardian) { Guardian.new(current_user) }
let(:dependencies) { { guardian: } }

subject(:result) { described_class.call(**dependencies) }

context "when in january" do
before { freeze_time DateTime.parse("2021-01-22") }

Expand All @@ -32,12 +32,14 @@
end

context "when reports is cached" do
before { freeze_time DateTime.parse("2021-12-22") }

it "returns the cached reports" do
expect(result.reports.length).to eq(9)

expect(DiscourseRewind::Action::TopWords).not_to receive(:call)

allow(DiscourseRewind::Action::TopWords).to receive(:call)
expect(result.reports.length).to eq(9)
expect(DiscourseRewind::Action::TopWords).to_not have_received(:call)
end
end

Expand All @@ -48,8 +50,9 @@
end

it "returns the reports" do
expect(DiscourseRewind::Action::TopWords).to receive(:call)
allow(DiscourseRewind::Action::TopWords).to receive(:call)
expect(result.reports.length).to eq(9)
expect(DiscourseRewind::Action::TopWords).to have_received(:call)
end
end
end
Expand Down
Loading