-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c839b95
commit 4fd0889
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
class CreateLineupJob < ApplicationJob | ||
def perform | ||
Lineup.create_next | ||
while Lineup.current.nil? | ||
Lineup.create_next | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require "rails_helper" | ||
|
||
describe CreateLineupJob do | ||
context "when there is a Lineup from yesterday" do | ||
let(:current_on) { Date.yesterday } | ||
|
||
it "creates a Lineup for today" do | ||
FactoryBot.create(:lineup, current_on: current_on) | ||
expect(Lineup.current).to be_nil | ||
expect do | ||
CreateLineupJob.new.perform | ||
end.to change(Lineup, :count).from(1).to(2) | ||
expect(Lineup.current).to_not be_nil | ||
end | ||
end | ||
|
||
context "when there is a gap in Lineup records" do | ||
let(:current_on) { Date.today - 7.days } | ||
|
||
it "creates enough Lineup records to catch up" do | ||
FactoryBot.create(:lineup, current_on: current_on) | ||
expect(Lineup.current).to be_nil | ||
expect do | ||
CreateLineupJob.new.perform | ||
end.to change(Lineup, :count).from(1).to(8) | ||
expect(Lineup.current).to_not be_nil | ||
end | ||
end | ||
end |