Skip to content

DEV: fix spec failure #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 26, 2025
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