Commit Graph

238 Commits

Author SHA1 Message Date
Daniel Schädler 3dfeae8bf3 Test #teams_sorted_by_group_scores 2019-06-18 22:22:10 +02:00
Daniel Schädler 15e2bd830f Randomize points in group_scores factory 2019-06-18 22:22:10 +02:00
Daniel Schädler 4925ea9d83 Make teams added to PlayoffStage configurable 2019-06-18 22:22:10 +02:00
Daniel Schädler 748ac18b35 Implement finished_group_match factory 2019-06-18 22:22:10 +02:00
Daniel Schädler 4e72d015ff Implement method to check if stage is over 2019-06-18 19:22:05 +02:00
Daniel Schädler 68efd3caae Add factory for a finished_playoff_match 2019-06-18 19:22:05 +02:00
Daniel Schädler bc0c7fddc3 Make match position randomizable 2019-06-18 19:22:05 +02:00
Daniel Schädler 386155a690 Fix last Match not being stopped correctly 2019-06-18 14:09:29 +02:00
Thor77 3109308817 Fix teams not associated with created tournament
when choosing a group stage
2019-06-18 13:29:31 +02:00
Daniel Schädler 7630f6b432 Fix Typo 2019-06-17 15:02:30 +02:00
Daniel Schädler 6dff05b5e6 Test AdvanceTeamsInIntermediateStage Interactor 2019-06-17 15:02:30 +02:00
Daniel Schädler f35ba5c745 Create factory for :single_team_match 2019-06-17 15:02:30 +02:00
Daniel Schädler e0da9ff7b5 Assign empty array if object_to_save is nil before pushing values to it
https://stackoverflow.com/questions/12163625/create-or-append-to-array-in-ruby
2019-06-17 15:02:30 +02:00
Daniel Schädler c9e1e153df Add interactor to advance all teams stuck in single team matches
After playoffs are created, before saving the stage this interactor
goes to the intermediate stage, looks for all the matches that are
:single_team matches and populates the match below with their respective
"winner".
2019-06-17 15:02:30 +02:00
Daniel Schädler 98319e9625 Assign :intermediate_stage to first stage if single_team matches present 2019-06-17 15:02:30 +02:00
Daniel Schädler 62f3ccba31 Rename method test 2019-06-17 15:02:30 +02:00
Daniel Schädler 5f378f27b2 Correct position for :single_team matches 2019-06-17 15:02:30 +02:00
Thor77 ce154a821c
Fix error message not changed in spec 2019-06-17 13:48:50 +02:00
Thor77 175870ab42
Prevent betting on running/finished matches 2019-06-17 13:48:50 +02:00
Thor77 48fc9fab57
Refactor spec to use let instead of class vars 2019-06-17 13:48:50 +02:00
Thor77 167a2116f1
Prevent duplicate bets on the same match 2019-06-17 13:48:50 +02:00
Thor77 ba758c73ff
Fix mock using throw instead of raise 2019-06-17 13:48:50 +02:00
Thor77 f08c4693ad
Expect UserServiceError in spec 2019-06-17 13:48:49 +02:00
Thor77 45ede9029e
Add :bet factory 2019-06-17 13:48:49 +02:00
Thor77 76e301e920
Add BetsController 2019-06-17 13:48:49 +02:00
Thor77 2f0127897e
Add UserService 2019-06-17 13:48:49 +02:00
Thor77 f3431e8442
Add bet model
* has_many relations in all belonging models
* specs for relations in existing models
* association specs for bet model
2019-06-17 13:48:49 +02:00
Daniel Schädler db70e33882 Assign number to each group 2019-06-17 13:37:06 +02:00
Daniel Schädler c2056df1ba Remove accidental focus: true 2019-06-17 13:37:06 +02:00
Daniel Schädler a74030a7ef Implement GroupsController 2019-06-16 13:22:15 +02:00
Daniel Schädler fc96b8f788 Correctly raise exceptions in mock 2019-06-14 15:53:12 +02:00
Daniel Schädler 41194ee181 Test group_stage state being assigned correctly 2019-06-13 16:13:06 +02:00
Daniel Schädler bb1b8798d8 DRY out group_stage_service_spec 2019-06-13 16:09:38 +02:00
Daniel Schädler 63db00b9ff Actually test if correct field gets set in error response 2019-06-13 13:28:34 +02:00
Daniel Schädler c8f69ccb16 Dry out tests for unacceptable playoff_teams_amount 2019-06-13 13:21:24 +02:00
Daniel Schädler 07f5388f6d Add Tests for TournamentService 2019-06-13 13:21:24 +02:00
Daniel Schädler 2e336262aa Add state to stage
This state is required to stop the group stage and trigger playoff
generation, it is (for now) irrelevant for anything other than that.
2019-06-13 13:21:24 +02:00
Daniel Schädler 4f64afd5fe Assign values to playoff transition relevant variables in factory 2019-06-13 13:21:24 +02:00
Daniel Schädler 3e04584e9f Test changing group_stage transition relevant parameters 2019-06-13 13:21:24 +02:00
Daniel Schädler 36bdfbae28 Add default for playoff_teams_amount to tournament factory 2019-06-13 13:21:24 +02:00
Daniel Schädler f04c11427a Assign default values on Group Stage creation
default values are assigned to instant_finalists_amount and
intermediate_round_participants_amount depending on playoff_teams_amount and group amount
2019-06-13 13:21:24 +02:00
Daniel Schädler 4d5d7bc812 Only allow positive powers of two for playoff_teams_amount 2019-06-13 13:21:24 +02:00
Daniel Schädler d8a9b27ab3 Add test type to all interactor tests 2019-06-13 13:21:24 +02:00
Daniel Schädler 5d47ae5426 Fix two typos 2019-06-05 17:05:58 +02:00
Daniel Schädler 9c9a856265 Test returning unprocessable entity when error occurs in match population 2019-06-05 17:05:58 +02:00
Daniel Schädler 41b8bdce77 Test unprocessable entity response on a match that is not ready
Unprocessable entity is returned when you try to start a match that is
not ready yet.
2019-06-05 17:05:58 +02:00
Daniel Schädler d03ceeffa4 Test returning unprocessable entity response
We now test sending a senseless state and also what happens when the
match.update method fails for some reason.
2019-06-05 17:05:58 +02:00
Daniel Schädler ab33ec157d Split test methods for failed stopping of matches 2019-06-05 17:05:58 +02:00
Daniel Schädler 68535b89fc Prevent matches from being stopped without a winner in playoffs 2019-06-05 17:05:58 +02:00
Daniel Schädler 2b7d0edf74 Correct state of empty_prepared_playoff_match factory 2019-06-05 17:05:58 +02:00
Daniel Schädler bd2af09339 Add field to tournament containing playoff_teams_amount
This field represents how many teams advance into playoff stage after
the group stage has ended.
2019-06-05 16:46:06 +02:00
Daniel Schädler 15e344fa2e Test returning unprocessable entity when match_score update fails 2019-06-05 10:13:26 +02:00
Daniel Schädler 24ce5b7a62 Test update_group_scores method 2019-06-05 09:49:22 +02:00
Daniel Schädler 258e1ceb1c Rename groups to prepared_groups
This is done because prepared_groups only represents hashes of groups
that still need to be generated rather then actual group objects.
2019-06-05 09:49:22 +02:00
Daniel Schädler c9cdb835a0 Remove unused Variable stage 2019-06-05 09:49:22 +02:00
Daniel Schädler ceea95c3d3 Move scope of tournament creation in match_score controller test
This fixes the problem we had with the update of the match score
returning :forbidden because the @owner variable was not set properly.

Also names of the tests should now be easier to read.
2019-06-05 09:49:21 +02:00
Daniel Schädler 60f12430af Dry out code with shared_examples 2019-06-05 09:49:21 +02:00
Daniel Schädler b51513661f Overwrite owner of tournament manually 2019-06-05 09:49:21 +02:00
Daniel Schädler d9c901615e Test if match_score point change triggers group score calculation 2019-06-05 09:49:21 +02:00
Daniel Schädler f97c8e501c Remove unnecessary :group_stage_only tournament 2019-06-05 09:49:21 +02:00
Daniel Schädler 5925f23720 Make Match Factory configurable for group_stage and group factory 2019-06-05 09:49:21 +02:00
Daniel Schädler c674e5fcab Add group_scores to groups factory, one for every team 2019-06-05 09:49:21 +02:00
Daniel Schädler 96398706ea Add GroupScore objects for every team to the group stage 2019-06-05 09:49:21 +02:00
Daniel Schädler 957788651c Update group_scores on match_score change if match is a group match 2019-06-05 09:49:21 +02:00
Daniel Schädler 564cec2820 Add method to check if match_score is part of a group match 2019-06-05 09:49:21 +02:00
Daniel Schädler 752beefca6 Correctly handle matches that are not started yet 2019-06-05 09:49:21 +02:00
Daniel Schädler e868e936e4 Implement Methods returning points of teams per match
These methods return group_points scored_points and received_points
respectively when given a team that is present in the match
They return 0 when given a team that isn't contesting in that match
2019-06-05 09:26:11 +02:00
Daniel Schädler 990361a25b Fix comparison that got lost in refactoring 2019-05-27 13:25:14 +02:00
Daniel Schädler a710addde7 Create :stage_tournaments with realistic match positions 2019-05-26 22:03:22 +02:00
Daniel Schädler 537cccfa9e Force save match_scores 2019-05-26 20:15:59 +02:00
Daniel Schädler 6f44823bc6 Change match state of match below 2019-05-26 20:15:59 +02:00
Daniel Schädler 8dd1f0b07c Rearrange Test Code 2019-05-26 20:15:59 +02:00
Daniel Schädler 9f92ca7e5b Move stopping of matches test 2019-05-26 20:15:59 +02:00
Daniel Schädler d61b3b2b63 Fix factory name for stageless tournament 2019-05-26 20:15:59 +02:00
Daniel Schädler 21c79665e1 Check if .winner returns a Team
This is done to prevent Test from succeeding if both
.winner and .teams return nil
2019-05-26 20:15:59 +02:00
Daniel Schädler 74b345dce4 Fix factory name for stage tournament 2019-05-26 20:15:59 +02:00
Daniel Schädler 5457d50277 Simplify code finding the tournament
Co-Authored-By: Thor77 <thor77@thor77.org>
2019-05-26 20:15:59 +02:00
Daniel Schädler 0337b6fad8 Save match_scores after editing them in tests 2019-05-26 20:15:59 +02:00
Daniel Schädler d0d38a7972 Test populate_match_below Interactor 2019-05-26 20:15:58 +02:00
Daniel Schädler e0ef39cc4b Test populate_match_below method 2019-05-26 20:15:58 +02:00
Daniel Schädler d2f5d3594e Test performance optimization
In general this generates less unnecessary faker data
2019-05-26 20:15:16 +02:00
Daniel Schädler bc055843d9 Test stopping of Matches 2019-05-26 20:14:13 +02:00
Daniel Schädler 2f77d2d25b Add winner method to match 2019-05-26 20:14:13 +02:00
Daniel Schädler 280b0c1dec Change status of Match to only represent being finished
The winner will be a attribute of the Match instead of something
that is written in its status.
2019-05-26 20:14:13 +02:00
Daniel Schädler 8388af20f0 Generalize tournament save interactor
It now is responsible for saving all ApplicationRecord objects to the
database. This will reduce code duplication one we have other objects
that need to be saved. (As we will soon need to save individual matches)
2019-05-26 20:14:13 +02:00
Daniel Schädler 51056d340c Save the whole stage instead of the single matches 2019-05-22 09:25:07 +02:00
Daniel Schädler b36e3c4251 Delegate owner of team to tournament again 2019-05-22 09:25:07 +02:00
Daniel Schädler 27709f0136 This change will basically solve climate change as it saves all
the computing power in the whole world.
2019-05-22 09:25:07 +02:00
Thor77 b5377db1f3 Reformat indention 2019-05-22 09:25:07 +02:00
Daniel Schädler d548eee245 Change .map to .each 2019-05-22 09:25:07 +02:00
Daniel Schädler dcb19461be Add group_stage_only_tournament factory 2019-05-22 09:25:07 +02:00
Daniel Schädler 03d7369a1c Remove link between team.owner and tournament 2019-05-22 09:25:07 +02:00
Daniel Schädler f73820f2f2 Reduce standart amount of teams within a tournament to 8 2019-05-22 09:25:07 +02:00
Daniel Schädler 3f4c6336c2 Add dummy_stage_tournament 2019-05-22 09:25:07 +02:00
Daniel Schädler c55b45bdc1 Add position to all matches 2019-05-22 09:25:07 +02:00
Daniel Schädler 80b14900d0 Makes match_type configurable instead of only setting its state 2019-05-22 09:25:07 +02:00
Daniel Schädler b9afa956ce Add empty_prepared_playoff_match 2019-05-22 09:25:07 +02:00
Thor77 42d9b0957f Save match position 2019-05-22 09:25:07 +02:00
Daniel Schädler 8a70d5f333 For stage tournament, first stage has running matches 2019-05-22 09:25:07 +02:00
Daniel Schädler cb82ca44d8 Put running playoff matches in a playoff stage (only on first level) 2019-05-22 09:25:07 +02:00