-
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.
added updating oraculs lineups points for cups
- Loading branch information
Showing
13 changed files
with
169 additions
and
45 deletions.
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
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
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
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
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
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
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
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
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
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
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
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
51 changes: 38 additions & 13 deletions
51
spec/services/oraculs/lineups/points/update_service_spec.rb
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,24 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
describe Oraculs::Lineups::Points::UpdateService, type: :service do | ||
subject(:service_call) { described_class.new.call(week_id: week.id) } | ||
subject(:service_call) { | ||
described_class.new.call(periodable_id: periodable.id, periodable_type: periodable.class.name) | ||
} | ||
|
||
let!(:week) { create :week } | ||
let!(:oraculs_lineup) { create :oraculs_lineup, periodable: week } | ||
context 'for week' do | ||
let!(:periodable) { create :week } | ||
let!(:oraculs_lineup) { create :oraculs_lineup, periodable: periodable } | ||
|
||
before do | ||
game1 = create :game, week: week, points: [1, 0] | ||
game2 = create :game, week: week, points: [1, 0] | ||
game3 = create :game, week: week, points: [1, 0] | ||
before do | ||
game1 = create :game, week: periodable, points: [1, 0] | ||
game2 = create :game, week: periodable, points: [1, 0] | ||
game3 = create :game, week: periodable, points: [1, 0] | ||
|
||
create :oraculs_forecast, oraculs_lineup: oraculs_lineup, forecastable: game1, value: [1, 0] | ||
create :oraculs_forecast, oraculs_lineup: oraculs_lineup, forecastable: game2, value: [2, 0] | ||
create :oraculs_forecast, oraculs_lineup: oraculs_lineup, forecastable: game3, value: [0, 3] | ||
create :oraculs_forecast, oraculs_lineup: oraculs_lineup, forecastable: game1, value: [1, 0] | ||
create :oraculs_forecast, oraculs_lineup: oraculs_lineup, forecastable: game2, value: [2, 0] | ||
create :oraculs_forecast, oraculs_lineup: oraculs_lineup, forecastable: game3, value: [0, 3] | ||
end | ||
|
||
it 'updates points' do | ||
service_call | ||
|
||
expect(oraculs_lineup.reload.points).to eq 4 | ||
end | ||
end | ||
|
||
it 'updates points' do | ||
service_call | ||
context 'for cups round' do | ||
let!(:periodable) { create :cups_round } | ||
let!(:oraculs_lineup) { create :oraculs_lineup, periodable: periodable } | ||
|
||
before do | ||
cups_pair1 = create :cups_pair, cups_round: periodable, points: [1, 0] | ||
cups_pair2 = create :cups_pair, cups_round: periodable, points: [1, 0] | ||
cups_pair3 = create :cups_pair, cups_round: periodable, points: [1, 0] | ||
|
||
create :oraculs_forecast, oraculs_lineup: oraculs_lineup, forecastable: cups_pair1, value: [1, 0] | ||
create :oraculs_forecast, oraculs_lineup: oraculs_lineup, forecastable: cups_pair2, value: [2, 0] | ||
create :oraculs_forecast, oraculs_lineup: oraculs_lineup, forecastable: cups_pair3, value: [0, 3] | ||
end | ||
|
||
it 'updates points' do | ||
service_call | ||
|
||
expect(oraculs_lineup.reload.points).to eq 4 | ||
expect(oraculs_lineup.reload.points).to eq 4 | ||
end | ||
end | ||
end |