36
36
end
37
37
38
38
describe Game , "saving of cross variant achievements" do
39
-
39
+
40
40
before :each do
41
41
clean_database
42
42
$user = User . create ( :login => "test_user" )
@@ -60,24 +60,41 @@ def update_games
60
60
expect ( Event . count ) . to eq 0
61
61
62
62
Game . create ( params )
63
- repository . adapter . execute "UPDATE games SET version= 'v'|| id"
63
+ repository . adapter . execute "UPDATE games SET version = 'v' || id"
64
64
update_games
65
+
65
66
expect ( Individualtrophy . count ) . to eq 4
66
- expect ( Individualtrophy . all . map ( &:trophy ) . sort ) . to eq [ "anti_stoner_1" , "ascended_variants_1" , "globetrotter_1" , "sightseeing_tour_1" ]
67
- expect ( Event . count ) . to eq 4
68
- expect ( Event . all . map ( &:text ) . sort ) . to eq (
69
- [ 'Achievement "Diversity Ascender: Ascended one variant" unlocked by test_user!' ,
70
- 'Achievement "Sightseeing Tour: finish a game in one variant" unlocked by test_user!' ,
71
- 'Achievement "Anti-Stoner: defeated Medusa in one variant" unlocked by test_user!' ,
72
- 'Achievement "Globetrotter: get a trophy in one variant" unlocked by test_user!' ] . sort
73
- )
67
+ expect ( Individualtrophy . all . map ( &:trophy ) . sort ) . to match_array ( [
68
+ 'anti_stoner_1' ,
69
+ 'ascended_variants_1' ,
70
+ 'globetrotter_1' ,
71
+ 'sightseeing_tour_1'
72
+ ] )
73
+
74
+ # spam protection, no events generated
75
+ expect ( Event . count ) . to eq 0
74
76
75
77
Game . create ( params )
76
- repository . adapter . execute "UPDATE games SET version= 'v'|| id"
78
+ repository . adapter . execute "UPDATE games SET version = 'v' || id"
77
79
update_games
78
- expect ( Individualtrophy . all . map ( &:trophy ) ) . to include "anti_stoner_2"
80
+
81
+ expect ( Individualtrophy . all . map ( &:trophy ) . sort ) . to match_array ( [
82
+ 'anti_stoner_1' ,
83
+ 'anti_stoner_2' ,
84
+ 'ascended_variants_1' ,
85
+ 'ascended_variants_2' ,
86
+ 'globetrotter_1' ,
87
+ 'globetrotter_2' ,
88
+ 'sightseeing_tour_1' ,
89
+ 'sightseeing_tour_2'
90
+ ] )
91
+
79
92
expect ( Individualtrophy . count ) . to eq 8
80
- expect ( Event . all . map ( &:text ) ) . to include 'Achievement "Anti-Stoner: defeated Medusa in two variants" unlocked by test_user!'
81
- expect ( Event . count ) . to eq 8
93
+ expect ( Event . all . map ( &:text ) ) . to match_array ( [
94
+ 'Achievement "Anti-Stoner: defeated Medusa in two variants" unlocked by test_user!' ,
95
+ 'Achievement "Diversity Ascender: Ascended two variants" unlocked by test_user!'
96
+ ] )
97
+ # because of spam protection, only the 2 last achievements generated events
98
+ expect ( Event . count ) . to eq 2
82
99
end
83
100
end
0 commit comments