rating-chgk-v2 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/rating_chgk_v2/endpoints/base_endpoint.rb +3 -2
- data/lib/rating_chgk_v2/request.rb +0 -1
- data/lib/rating_chgk_v2/version.rb +1 -1
- data/lib/rating_chgk_v2.rb +1 -1
- data/rating-chgk-v2.gemspec +0 -2
- metadata +4 -91
- data/spec/lib/rating_chgk_v2/collections/base_collection_spec.rb +0 -53
- data/spec/lib/rating_chgk_v2/collections/countries_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/player_seasons_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/player_tournaments_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/players_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/regions_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/releases_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/seasons_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/teams_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/tournaments_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/towns_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/venue_types_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/venues_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/connection_spec.rb +0 -22
- data/spec/lib/rating_chgk_v2/endpoints/base_endpoint_spec.rb +0 -15
- data/spec/lib/rating_chgk_v2/error_spec.rb +0 -11
- data/spec/lib/rating_chgk_v2/models/country_model_spec.rb +0 -30
- data/spec/lib/rating_chgk_v2/models/player_model_spec.rb +0 -59
- data/spec/lib/rating_chgk_v2/models/season_model_spec.rb +0 -36
- data/spec/lib/rating_chgk_v2/models/team_model_spec.rb +0 -35
- data/spec/lib/rating_chgk_v2/models/tournament_model_spec.rb +0 -38
- data/spec/lib/rating_chgk_v2/models/venue_model_spec.rb +0 -30
- data/spec/lib/rating_chgk_v2/rest/authentication_token_spec.rb +0 -19
- data/spec/lib/rating_chgk_v2/rest/countries_spec.rb +0 -94
- data/spec/lib/rating_chgk_v2/rest/players_spec.rb +0 -126
- data/spec/lib/rating_chgk_v2/rest/regions_spec.rb +0 -37
- data/spec/lib/rating_chgk_v2/rest/releases_spec.rb +0 -34
- data/spec/lib/rating_chgk_v2/rest/seasons_spec.rb +0 -71
- data/spec/lib/rating_chgk_v2/rest/teams_spec.rb +0 -66
- data/spec/lib/rating_chgk_v2/rest/tournament_flags_spec.rb +0 -27
- data/spec/lib/rating_chgk_v2/rest/tournament_synch_appeals_spec.rb +0 -22
- data/spec/lib/rating_chgk_v2/rest/tournament_synch_controversials_spec.rb +0 -20
- data/spec/lib/rating_chgk_v2/rest/tournament_synch_requests_spec.rb +0 -20
- data/spec/lib/rating_chgk_v2/rest/tournament_types_spec.rb +0 -23
- data/spec/lib/rating_chgk_v2/rest/tournaments_spec.rb +0 -89
- data/spec/lib/rating_chgk_v2/rest/towns_spec.rb +0 -35
- data/spec/lib/rating_chgk_v2/rest/venue_types_spec.rb +0 -46
- data/spec/lib/rating_chgk_v2/rest/venues_spec.rb +0 -71
- data/spec/lib/rating_chgk_v2_spec.rb +0 -9
- data/spec/spec_helper.rb +0 -37
- data/spec/support/shared/paginated.rb +0 -41
- data/spec/support/test_client.rb +0 -7
- data/spec/support/vcr.rb +0 -15
@@ -1,94 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::Countries do
|
4
|
-
describe '#countries' do
|
5
|
-
it 'returns a collection of countries' do
|
6
|
-
countries = VCR.use_cassette('countries/all_countries') do
|
7
|
-
test_client.countries
|
8
|
-
end
|
9
|
-
|
10
|
-
expect(countries[1].name).to eq('Австралия')
|
11
|
-
expect(countries[1].id).to eq(2)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'returns a collection of countries with params' do
|
15
|
-
countries = VCR.use_cassette('countries/all_countries_params') do
|
16
|
-
test_client.countries itemsPerPage: 2, name: 'Бе'
|
17
|
-
end
|
18
|
-
|
19
|
-
expect(countries.items.size).to eq(2)
|
20
|
-
expect(countries.first.name).to eq('Беларусь')
|
21
|
-
expect(countries.first.id).to eq(5)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#create_country' do
|
26
|
-
before { RatingChgkV2.reset_client! }
|
27
|
-
|
28
|
-
after { RatingChgkV2.reset_client! }
|
29
|
-
|
30
|
-
it 'raises an error when the token is invalid' do
|
31
|
-
custom_client = RatingChgkV2.client token: 'fake_token'
|
32
|
-
|
33
|
-
expect do
|
34
|
-
VCR.use_cassette('countries/create_country_incorrect_token') do
|
35
|
-
custom_client.create_country name: 'test'
|
36
|
-
end
|
37
|
-
end.to raise_error(RatingChgkV2::Error::Unauthorized)
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'creates a country' do
|
41
|
-
stub_request(:post, 'https://api.rating.chgk.net/countries').
|
42
|
-
with(body: {name: 'Темерия'}).
|
43
|
-
to_return(
|
44
|
-
status: 200,
|
45
|
-
body: '{"id":0,"name":"Темерия"}',
|
46
|
-
headers: {}
|
47
|
-
)
|
48
|
-
|
49
|
-
country = test_client.create_country name: 'Темерия'
|
50
|
-
expect(country.name).to eq('Темерия')
|
51
|
-
expect(country.id).to eq(0)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
specify '#update_country' do
|
56
|
-
stub_request(:put, 'https://api.rating.chgk.net/countries/0').
|
57
|
-
with(body: {name: 'Лирия'}).
|
58
|
-
to_return(
|
59
|
-
status: 200,
|
60
|
-
body: '{"id":0,"name":"Лирия"}',
|
61
|
-
headers: {}
|
62
|
-
)
|
63
|
-
|
64
|
-
country = test_client.update_country 0, name: 'Лирия'
|
65
|
-
expect(country.name).to eq('Лирия')
|
66
|
-
expect(country.id).to eq(0)
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '#delete_country' do
|
70
|
-
it 'raises an error when the token is invalid' do
|
71
|
-
expect do
|
72
|
-
VCR.use_cassette('countries/delete_country_incorrect_token') do
|
73
|
-
test_client.delete_country 1
|
74
|
-
end
|
75
|
-
end.to raise_error(RatingChgkV2::Error::Unauthorized)
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'deletes a country' do
|
79
|
-
stub_request(:delete, 'https://api.rating.chgk.net/countries/1').to_return(status: 204, body: '', headers: {})
|
80
|
-
|
81
|
-
expect(test_client.delete_country(1)).to eq('')
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
specify '#country' do
|
86
|
-
id = 20
|
87
|
-
country = VCR.use_cassette('countries/country') do
|
88
|
-
test_client.country id
|
89
|
-
end
|
90
|
-
|
91
|
-
expect(country.name).to eq('Нидерланды')
|
92
|
-
expect(country.id).to eq(id)
|
93
|
-
end
|
94
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::Players do
|
4
|
-
let(:player_id) { 1110 }
|
5
|
-
|
6
|
-
specify '#player' do
|
7
|
-
player = VCR.use_cassette('players/player') do
|
8
|
-
test_client.player(player_id)
|
9
|
-
end
|
10
|
-
|
11
|
-
expect(player.id).to eq(player_id)
|
12
|
-
expect(player.name).to eq('Александр')
|
13
|
-
expect(player.surname).to eq('Андрианов')
|
14
|
-
expect(player.patronymic).to eq('Сергеевич')
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#player_tournaments' do
|
18
|
-
it 'returns a collection of player tournaments' do
|
19
|
-
player_tournaments = VCR.use_cassette('players/player_tournaments') do
|
20
|
-
test_client.player_tournaments player_id
|
21
|
-
end
|
22
|
-
|
23
|
-
expect(player_tournaments).to be_an_instance_of(RatingChgkV2::Collections::PlayerTournamentsCollection)
|
24
|
-
tour = player_tournaments.first
|
25
|
-
|
26
|
-
expect(tour.idplayer).to eq(player_id)
|
27
|
-
expect(tour.idtournament).to eq(314)
|
28
|
-
expect(tour.idteam).to eq(7121)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'returns a collection of player tournaments next page' do
|
32
|
-
player_tournaments = VCR.use_cassette('players/player_tournaments_params') do
|
33
|
-
test_client.player_tournaments player_id, itemsPerPage: 2
|
34
|
-
end
|
35
|
-
|
36
|
-
tour = player_tournaments[1]
|
37
|
-
|
38
|
-
expect(tour.idplayer).to eq(player_id)
|
39
|
-
expect(tour.idtournament).to eq(400)
|
40
|
-
expect(tour.idteam).to eq(7456)
|
41
|
-
|
42
|
-
VCR.use_cassette('players/player_tournaments_next_page') do
|
43
|
-
player_tournaments.next_page!
|
44
|
-
end
|
45
|
-
|
46
|
-
tour = player_tournaments[0]
|
47
|
-
|
48
|
-
expect(tour.idplayer).to eq(player_id)
|
49
|
-
expect(tour.idtournament).to eq(314)
|
50
|
-
expect(tour.idteam).to eq(7121)
|
51
|
-
expect(player_tournaments.endpoint.params[:itemsPerPage]).to eq(2)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '#player_seasons' do
|
56
|
-
it 'returns a collection of player seasons' do
|
57
|
-
player_seasons = VCR.use_cassette('players/player_seasons') do
|
58
|
-
test_client.player_seasons player_id
|
59
|
-
end
|
60
|
-
|
61
|
-
expect(player_seasons).to be_an_instance_of(RatingChgkV2::Collections::PlayerSeasonsCollection)
|
62
|
-
season = player_seasons.first
|
63
|
-
|
64
|
-
expect(season.idplayer).to eq(player_id)
|
65
|
-
expect(season.idseason).to eq(7)
|
66
|
-
expect(season.idteam).to eq(7121)
|
67
|
-
expect(season.dateAdded).to eq('2007-09-23T00:00:00+04:00')
|
68
|
-
expect(season.dateRemoved).to be_nil
|
69
|
-
expect(season.playerNumber).to eq(0)
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'returns seasons by params' do
|
73
|
-
player_seasons = VCR.use_cassette('players/player_seasons_params') do
|
74
|
-
test_client.player_seasons player_id, itemsPerPage: 2, idseason: 8, idteam: 7456
|
75
|
-
end
|
76
|
-
|
77
|
-
expect(player_seasons).to be_an_instance_of(RatingChgkV2::Collections::PlayerSeasonsCollection)
|
78
|
-
season = player_seasons.first
|
79
|
-
|
80
|
-
expect(season.idplayer).to eq(player_id)
|
81
|
-
expect(season.idseason).to eq(8)
|
82
|
-
expect(season.idteam).to eq(7456)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#players' do
|
87
|
-
it 'returns a collection of players' do
|
88
|
-
players = VCR.use_cassette('players/all_players') do
|
89
|
-
test_client.players
|
90
|
-
end
|
91
|
-
|
92
|
-
expect(players[0].surname).to eq('Абабилов')
|
93
|
-
expect(players[0].id).to eq(1)
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'returns next page' do
|
97
|
-
players = VCR.use_cassette('players/all_players_params') do
|
98
|
-
test_client.players itemsPerPage: 3, page: 2
|
99
|
-
end
|
100
|
-
|
101
|
-
expect(players[0].name).to eq('Артур')
|
102
|
-
expect(players[0].id).to eq(12)
|
103
|
-
|
104
|
-
VCR.use_cassette('players/all_players_next_page') do
|
105
|
-
players.next_page!
|
106
|
-
end
|
107
|
-
|
108
|
-
expect(players[0].name).to eq('Олег')
|
109
|
-
expect(players[0].id).to eq(15)
|
110
|
-
expect(players.endpoint.params[:itemsPerPage]).to eq(3)
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'returns previous page' do
|
114
|
-
players = VCR.use_cassette('players/all_players_params') do
|
115
|
-
test_client.players itemsPerPage: 3, page: 2
|
116
|
-
end
|
117
|
-
|
118
|
-
VCR.use_cassette('players/all_players_prev_page') do
|
119
|
-
players.prev_page!
|
120
|
-
end
|
121
|
-
|
122
|
-
expect(players[0].surname).to eq('Абабилов')
|
123
|
-
expect(players.endpoint.params[:itemsPerPage]).to eq(3)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::Regions do
|
4
|
-
describe '#regions' do
|
5
|
-
it 'returns a collection of regions' do
|
6
|
-
regions = VCR.use_cassette('regions/all_regions') do
|
7
|
-
test_client.regions
|
8
|
-
end
|
9
|
-
|
10
|
-
expect(regions.last.name).to eq('Воронежская область')
|
11
|
-
expect(regions.last.id).to eq(30)
|
12
|
-
expect(regions.last.country['name']).to eq('Россия')
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'returns a collection of regions with params' do
|
16
|
-
regions = VCR.use_cassette('regions/all_regions_params') do
|
17
|
-
test_client.regions itemsPerPage: 3, country: 'Россия'
|
18
|
-
end
|
19
|
-
|
20
|
-
expect(regions.items.size).to eq(3)
|
21
|
-
expect(regions[1].name).to eq('Адыгея')
|
22
|
-
expect(regions[1].country['name']).to eq('Россия')
|
23
|
-
expect(regions[1].id).to eq(2)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
specify '#region' do
|
28
|
-
id = 3
|
29
|
-
region = VCR.use_cassette('regions/region') do
|
30
|
-
test_client.region id
|
31
|
-
end
|
32
|
-
|
33
|
-
expect(region.name).to eq('Акмолинская область')
|
34
|
-
expect(region.country['name']).to eq('Казахстан')
|
35
|
-
expect(region.id).to eq(id)
|
36
|
-
end
|
37
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::Releases do
|
4
|
-
describe '#releases' do
|
5
|
-
it 'returns a collection of releases' do
|
6
|
-
releases = VCR.use_cassette('releases/all_releases') do
|
7
|
-
test_client.releases
|
8
|
-
end
|
9
|
-
|
10
|
-
expect(releases.first.date).to eq('2003-07-01T00:00:00+04:00')
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'returns a collection of releases with params' do
|
14
|
-
releases = VCR.use_cassette('releases/all_releases_params') do
|
15
|
-
test_client.releases itemsPerPage: 3, page: 2
|
16
|
-
end
|
17
|
-
|
18
|
-
expect(releases.items.size).to eq(3)
|
19
|
-
expect(releases.first.realDate).to eq('2005-04-01T00:00:00+04:00')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
specify '#release' do
|
24
|
-
id = 4
|
25
|
-
release = VCR.use_cassette('releases/release') do
|
26
|
-
test_client.release id
|
27
|
-
end
|
28
|
-
|
29
|
-
expect(release.lastRunRefresh).to eq('2015-02-09T15:51:22+03:00')
|
30
|
-
expect(release.realDate).to eq('2005-04-01T00:00:00+04:00')
|
31
|
-
expect(release.date).to eq('2005-04-01T00:00:00+04:00')
|
32
|
-
expect(release.id).to eq(id)
|
33
|
-
end
|
34
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::Seasons do
|
4
|
-
describe '#seasons' do
|
5
|
-
it 'returns a collection of seasons' do
|
6
|
-
seasons = VCR.use_cassette('seasons/all_seasons') do
|
7
|
-
test_client.seasons
|
8
|
-
end
|
9
|
-
|
10
|
-
expect(seasons.first.dateStart).to eq('2002-09-01T00:00:00+04:00')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
specify '#season' do
|
15
|
-
id = 5
|
16
|
-
season = VCR.use_cassette('seasons/season') do
|
17
|
-
test_client.season id
|
18
|
-
end
|
19
|
-
|
20
|
-
expect(season.id).to eq(id)
|
21
|
-
expect(season.dateStart).to eq('1999-09-01T00:00:00+04:00')
|
22
|
-
expect(season.dateEnd).to eq('2000-08-31T00:00:00+04:00')
|
23
|
-
end
|
24
|
-
|
25
|
-
specify '#create_season' do
|
26
|
-
data = {
|
27
|
-
dateStart: '2022-02-05T19:37:45.004Z',
|
28
|
-
dateEnd: '2022-02-05T19:37:45.004Z'
|
29
|
-
}
|
30
|
-
stub_request(:post, 'https://api.rating.chgk.net/seasons').
|
31
|
-
with(body: data).
|
32
|
-
to_return(
|
33
|
-
status: 200,
|
34
|
-
body: JSON.dump(data.merge({id: 0})),
|
35
|
-
headers: {}
|
36
|
-
)
|
37
|
-
|
38
|
-
season = test_client.create_season data
|
39
|
-
|
40
|
-
expect(season.id).to eq(0)
|
41
|
-
expect(season.dateStart).to eq(data[:dateStart])
|
42
|
-
expect(season.dateEnd).to eq(data[:dateEnd])
|
43
|
-
end
|
44
|
-
|
45
|
-
specify '#update_season' do
|
46
|
-
data = {
|
47
|
-
dateStart: '2021-02-05T19:37:45.004Z',
|
48
|
-
dateEnd: '2021-02-05T19:37:45.004Z'
|
49
|
-
}
|
50
|
-
|
51
|
-
stub_request(:put, 'https://api.rating.chgk.net/seasons/0').
|
52
|
-
with(body: data).
|
53
|
-
to_return(
|
54
|
-
status: 200,
|
55
|
-
body: JSON.dump(data.merge({id: 0})),
|
56
|
-
headers: {}
|
57
|
-
)
|
58
|
-
|
59
|
-
season = test_client.update_season 0, data
|
60
|
-
|
61
|
-
expect(season.id).to eq(0)
|
62
|
-
expect(season.dateStart).to eq(data[:dateStart])
|
63
|
-
expect(season.dateEnd).to eq(data[:dateEnd])
|
64
|
-
end
|
65
|
-
|
66
|
-
specify '#delete_season' do
|
67
|
-
stub_request(:delete, 'https://api.rating.chgk.net/seasons/0').to_return(status: 204, body: '', headers: {})
|
68
|
-
|
69
|
-
expect(test_client.delete_season(0)).to eq('')
|
70
|
-
end
|
71
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::Teams do
|
4
|
-
let(:team_id) { 2 }
|
5
|
-
|
6
|
-
specify '#team' do
|
7
|
-
team = VCR.use_cassette('teams/team') do
|
8
|
-
test_client.team(team_id)
|
9
|
-
end
|
10
|
-
|
11
|
-
expect(team.id).to eq(team_id)
|
12
|
-
expect(team.name).to eq('Афина')
|
13
|
-
expect(team.town['id']).to eq(201)
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#teams' do
|
17
|
-
it 'returns a collection of teams' do
|
18
|
-
teams = VCR.use_cassette('teams/all_teams') do
|
19
|
-
test_client.teams
|
20
|
-
end
|
21
|
-
|
22
|
-
expect(teams[1].name).to eq('Афина')
|
23
|
-
expect(teams[1].id).to eq(2)
|
24
|
-
expect(teams[1].town['id']).to eq(201)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'returns a collection of teams with params' do
|
28
|
-
teams = VCR.use_cassette('teams/all_teams_params') do
|
29
|
-
test_client.teams itemsPerPage: 2, name: 'Н', page: 3
|
30
|
-
end
|
31
|
-
|
32
|
-
expect(teams.count).to eq(2)
|
33
|
-
expect(teams[0].name).to eq('Миллениум')
|
34
|
-
expect(teams[0].id).to eq(11)
|
35
|
-
expect(teams[0].town['id']).to eq(282)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#team_seasons' do
|
40
|
-
it 'returns seasons by params' do
|
41
|
-
team_seasons = VCR.use_cassette('teams/team_seasons_params') do
|
42
|
-
test_client.team_seasons team_id, idseason: 9
|
43
|
-
end
|
44
|
-
|
45
|
-
expect(team_seasons).to be_an_instance_of(RatingChgkV2::Collections::PlayerSeasonsCollection)
|
46
|
-
season = team_seasons.first
|
47
|
-
|
48
|
-
expect(season.idplayer).to eq(707)
|
49
|
-
expect(season.idseason).to eq(9)
|
50
|
-
expect(season.idteam).to eq(team_id)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '#team_tournaments' do
|
55
|
-
it 'returns a collection of team tournaments with params' do
|
56
|
-
team_tournaments = VCR.use_cassette('teams/team_tournaments_params') do
|
57
|
-
test_client.team_tournaments team_id, pagination: true
|
58
|
-
end
|
59
|
-
|
60
|
-
tour = team_tournaments[2]
|
61
|
-
|
62
|
-
expect(tour.idtournament).to eq(8)
|
63
|
-
expect(tour.idteam).to eq(team_id)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::TournamentFlags do
|
4
|
-
let(:id) { 2 }
|
5
|
-
|
6
|
-
describe '#tournament_flags' do
|
7
|
-
it 'returns a collection of tournament flags' do
|
8
|
-
flag = VCR.use_cassette('tournament_flags/all_tournament_flags') do
|
9
|
-
test_client.tournament_flags
|
10
|
-
end.first
|
11
|
-
|
12
|
-
expect(flag.id).to eq(1)
|
13
|
-
expect(flag.shortName).to eq('!')
|
14
|
-
expect(flag.longName).to eq('Общий зачёт')
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
specify '#tournament_flag' do
|
19
|
-
flag = VCR.use_cassette('tournament_flags/tournament_flag') do
|
20
|
-
test_client.tournament_flag id
|
21
|
-
end
|
22
|
-
|
23
|
-
expect(flag.id).to eq(id)
|
24
|
-
expect(flag.shortName).to eq('МШ')
|
25
|
-
expect(flag.longName).to eq('Младшие школьники (5-9 классы)')
|
26
|
-
end
|
27
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::TournamentSynchAppeals do
|
4
|
-
let(:id) { 1000 }
|
5
|
-
|
6
|
-
specify '#tournament_synch_appeal' do
|
7
|
-
appeal = VCR.use_cassette('tournament_synch_appeals/tournament_synch_appeal') do
|
8
|
-
test_client.tournament_synch_appeal id
|
9
|
-
end
|
10
|
-
|
11
|
-
expect(appeal.id).to eq(id)
|
12
|
-
expect(appeal.idtournament).to eq(2225)
|
13
|
-
expect(appeal.type).to eq('A')
|
14
|
-
expect(appeal.issuedAt).to eq('2013-04-19T22:28:10+04:00')
|
15
|
-
expect(appeal.status).to eq('D')
|
16
|
-
expect(appeal.appeal).to include('Из текста вопроса следует')
|
17
|
-
expect(appeal.comment).to include('В воспоминаниях фигурирует')
|
18
|
-
expect(appeal.overriddenBy).to be_nil
|
19
|
-
expect(appeal.questionNumber).to eq(8)
|
20
|
-
expect(appeal.answer).to be_nil
|
21
|
-
end
|
22
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::TournamentSynchControversials do
|
4
|
-
let(:id) { 1000 }
|
5
|
-
|
6
|
-
specify '#tournament_synch_controversial' do
|
7
|
-
contr = VCR.use_cassette('tournament_synch_controversial/tournament_synch_controversia') do
|
8
|
-
test_client.tournament_synch_controversial id
|
9
|
-
end
|
10
|
-
|
11
|
-
expect(contr.id).to eq(id)
|
12
|
-
expect(contr.questionNumber).to eq(26)
|
13
|
-
expect(contr.answer).to eq('валяться')
|
14
|
-
expect(contr.issuedAt).to eq('2012-01-31T09:26:32+04:00')
|
15
|
-
expect(contr.status).to eq('D')
|
16
|
-
expect(contr.comment).to eq('')
|
17
|
-
expect(contr.resolvedAt).to eq('2012-01-31T15:26:32+04:00')
|
18
|
-
expect(contr.appealJuryComment).to be_nil
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::TournamentSynchRequests do
|
4
|
-
let(:id) { 1000 }
|
5
|
-
|
6
|
-
specify '#tournament_synch_requests' do
|
7
|
-
req = VCR.use_cassette('tournament_synch_requests/tournament_synch_request') do
|
8
|
-
test_client.tournament_synch_request id
|
9
|
-
end
|
10
|
-
|
11
|
-
expect(req.id).to eq(id)
|
12
|
-
expect(req.status).to eq('A')
|
13
|
-
expect(req.venue['name']).to eq('Павлодар')
|
14
|
-
expect(req.representative['name']).to eq('Айбек')
|
15
|
-
expect(req.narrators.first['surname']).to eq('Логвиненко')
|
16
|
-
expect(req.approximateTeamsCount).to be_nil
|
17
|
-
expect(req.issuedAt).to eq('2012-09-21T10:30:14+04:00')
|
18
|
-
expect(req.tournamentId).to eq(2180)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::TournamentTypes do
|
4
|
-
let(:id) { 3 }
|
5
|
-
|
6
|
-
specify '#tournament_types' do
|
7
|
-
t_type = VCR.use_cassette('tournament_types/tournament_types') do
|
8
|
-
test_client.tournament_types
|
9
|
-
end.first
|
10
|
-
|
11
|
-
expect(t_type.id).to eq(1)
|
12
|
-
expect(t_type.name).to eq('Неизвестный')
|
13
|
-
end
|
14
|
-
|
15
|
-
specify '#tournament_type' do
|
16
|
-
t_type = VCR.use_cassette('tournament_types/tournament_type') do
|
17
|
-
test_client.tournament_type id
|
18
|
-
end
|
19
|
-
|
20
|
-
expect(t_type.id).to eq(id)
|
21
|
-
expect(t_type.name).to eq('Синхрон')
|
22
|
-
end
|
23
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::Tournaments do
|
4
|
-
let(:tournament_id) { 7798 }
|
5
|
-
|
6
|
-
# rubocop:disable RSpec/MultipleExpectations
|
7
|
-
specify '#tournament' do
|
8
|
-
tournament = VCR.use_cassette('tournaments/tournament') do
|
9
|
-
test_client.tournament(tournament_id)
|
10
|
-
end
|
11
|
-
|
12
|
-
expect(tournament.id).to eq(tournament_id)
|
13
|
-
expect(tournament.name).to eq('Игры доброй воли')
|
14
|
-
expect(tournament.lastEditDate).to eq('2022-03-30T09:34:21+03:00')
|
15
|
-
expect(tournament.dateStart).to eq('2022-03-13T13:00:00+03:00')
|
16
|
-
expect(tournament.dateEnd).to eq('2022-03-20T13:00:00+03:00')
|
17
|
-
expect(tournament.type['id']).to eq(3)
|
18
|
-
expect(tournament.orgcommittee.first['id']).to eq(14_450)
|
19
|
-
expect(tournament.synchData['dateRequestsAllowedTo']).to eq('2022-03-19T23:55:00+03:00')
|
20
|
-
expect(tournament.mainPayment).to eq(300)
|
21
|
-
expect(tournament.discountedPayment).to eq(100)
|
22
|
-
expect(tournament.discountedPaymentReason).to eq('школьные команды')
|
23
|
-
expect(tournament.currency).to eq('r')
|
24
|
-
expect(tournament.editors.first['id']).to eq(14_450)
|
25
|
-
expect(tournament.tournamentInRatingBalanced).to be(true)
|
26
|
-
expect(tournament.difficultyForecast).to eq(2.5)
|
27
|
-
expect(tournament.maiiAegis).to be(true)
|
28
|
-
expect(tournament.maiiAegisUpdatedAt).to eq('2022-02-12T08:35:02.372430Z')
|
29
|
-
expect(tournament.maiiRating).to be(true)
|
30
|
-
expect(tournament.maiiRatingUpdatedAt).to eq('2022-02-12T08:35:02.372192Z')
|
31
|
-
expect(tournament.questionQty['1']).to eq(9)
|
32
|
-
end
|
33
|
-
# rubocop:enable RSpec/MultipleExpectations
|
34
|
-
|
35
|
-
describe '#tournaments' do
|
36
|
-
it 'returns a collection of tournaments' do
|
37
|
-
tournaments = VCR.use_cassette('tournaments/all_tournaments') do
|
38
|
-
test_client.tournaments
|
39
|
-
end
|
40
|
-
|
41
|
-
expect(tournaments[0].name).to eq('Чемпионат Южного Кавказа')
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'returns a collection of tournaments with params' do
|
45
|
-
tournaments = VCR.use_cassette('tournaments/all_tournaments_params') do
|
46
|
-
test_client.tournaments itemsPerPage: 2, page: 3
|
47
|
-
end
|
48
|
-
|
49
|
-
expect(tournaments.count).to eq(2)
|
50
|
-
expect(tournaments[0].name).to eq('Бостонское чаепитие')
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
specify '#tournament_appeals' do
|
55
|
-
appeals = VCR.use_cassette('tournaments/appeals') do
|
56
|
-
test_client.tournament_appeals tournament_id
|
57
|
-
end
|
58
|
-
|
59
|
-
expect(appeals[0].id).to eq(12_153)
|
60
|
-
expect(appeals[0].questionNumber).to eq(20)
|
61
|
-
end
|
62
|
-
|
63
|
-
specify '#tournament_requests' do
|
64
|
-
requests = VCR.use_cassette('tournaments/requests') do
|
65
|
-
test_client.tournament_requests tournament_id
|
66
|
-
end
|
67
|
-
|
68
|
-
expect(requests[0].id).to eq(101_060)
|
69
|
-
expect(requests[0].status).to eq('A')
|
70
|
-
end
|
71
|
-
|
72
|
-
specify '#tournament_results' do
|
73
|
-
results = VCR.use_cassette('tournaments/results') do
|
74
|
-
test_client.tournament_results tournament_id, includeTeamMembers: 1, includeMasksAndControversials: 1,
|
75
|
-
includeTeamFlags: 1, includeRatingB: 1, town: 202
|
76
|
-
end.first
|
77
|
-
|
78
|
-
expect(results.team['id']).to eq(53_341)
|
79
|
-
expect(results.mask).to eq('011111111111011110001000000011111110111011111')
|
80
|
-
expect(results.current['name']).to eq('Парадные ватники')
|
81
|
-
expect(results.rating['b']).to eq(1216)
|
82
|
-
expect(results.controversials).to be_empty
|
83
|
-
expect(results.flags).to be_empty
|
84
|
-
expect(results.teamMembers.first['flag']).to eq('Б')
|
85
|
-
expect(results.questionsTotal).to eq(31)
|
86
|
-
expect(results.synchRequest['id']).to eq(103_475)
|
87
|
-
expect(results.position).to eq(1)
|
88
|
-
end
|
89
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::Towns do
|
4
|
-
let(:town_id) { 1 }
|
5
|
-
|
6
|
-
specify '#town' do
|
7
|
-
town = VCR.use_cassette('towns/town') do
|
8
|
-
test_client.town(town_id)
|
9
|
-
end
|
10
|
-
|
11
|
-
expect(town.id).to eq(town_id)
|
12
|
-
expect(town.name).to eq('Абакан')
|
13
|
-
expect(town.region['name']).to eq('Хакасия')
|
14
|
-
expect(town.country['name']).to eq('Россия')
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#towns' do
|
18
|
-
it 'returns a collection of towns' do
|
19
|
-
towns = VCR.use_cassette('towns/all_towns') do
|
20
|
-
test_client.towns
|
21
|
-
end
|
22
|
-
|
23
|
-
expect(towns[0].name).to eq('Абакан')
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'returns a collection of towns with params' do
|
27
|
-
towns = VCR.use_cassette('towns/all_towns_params') do
|
28
|
-
test_client.towns itemsPerPage: 2, page: 3
|
29
|
-
end
|
30
|
-
|
31
|
-
expect(towns.count).to eq(2)
|
32
|
-
expect(towns[0].name).to eq('Анапа')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|