Skip to content

Commit

Permalink
use role instead of the champion gg role value
Browse files Browse the repository at this point in the history
  • Loading branch information
danReynolds committed Dec 28, 2017
1 parent 9653337 commit 5646f8e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 46 deletions.
6 changes: 3 additions & 3 deletions app/controllers/summoners_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def summoner_params

def does_not_play_response(args, role, recency, champion = nil)
role_type = if role.present?
args[:role] = ChampionGGApi::ROLES[role.to_sym].humanize
args[:role] = role.to_s.humanize
:role_specified
else
:no_role_specified
Expand All @@ -305,7 +305,7 @@ def does_not_play_response(args, role, recency, champion = nil)

def multiple_roles_response(args, collection, recency)
args[:roles] = collection.sort.map do |role|
ChampionGGApi::ROLES[role.to_sym].humanize
role.to_s.humanize
end.en.conjunction(article: false)
recency_type = recency.present? ? :recency : :no_recency

Expand Down Expand Up @@ -426,7 +426,7 @@ def process_performance_request(options = {})
end
end
end
args[:role] = ChampionGGApi::ROLES[role.to_sym].humanize if role.present?
args[:role] = role.to_s.humanize if role.present?

@processed_request = {
args: args,
Expand Down
86 changes: 43 additions & 43 deletions spec/controllers/summoners_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
name: 'Hero man',
champion: 'Shyvana',
region: 'NA1',
role: 'DUO_CARRY',
role: 'ADC',
list_order: 'highest',
metric: '',
position_details: '',
Expand All @@ -478,13 +478,13 @@

before :each do
match_data = [
{ match: { win: true }, summoner_performance: { spell1_id: 3, spell2_id: 4, champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, summoner_performance: { spell1_id: 3, spell2_id: 4, champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, summoner_performance: { spell1_id: 3, spell2_id: 4, champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, summoner_performance: { spell1_id: 3, spell2_id: 4, champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, summoner_performance: { spell1_id: 3, spell2_id: 4, champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: false }, summoner_performance: { spell1_id: 4, spell2_id: 6, champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: false }, summoner_performance: { spell1_id: 4, spell2_id: 6, champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, summoner_performance: { spell1_id: 3, spell2_id: 4, champion_id: 102, role: 'ADC' } },
{ match: { win: true }, summoner_performance: { spell1_id: 3, spell2_id: 4, champion_id: 102, role: 'ADC' } },
{ match: { win: true }, summoner_performance: { spell1_id: 3, spell2_id: 4, champion_id: 102, role: 'ADC' } },
{ match: { win: true }, summoner_performance: { spell1_id: 3, spell2_id: 4, champion_id: 102, role: 'ADC' } },
{ match: { win: true }, summoner_performance: { spell1_id: 3, spell2_id: 4, champion_id: 102, role: 'ADC' } },
{ match: { win: false }, summoner_performance: { spell1_id: 4, spell2_id: 6, champion_id: 102, role: 'ADC' } },
{ match: { win: false }, summoner_performance: { spell1_id: 4, spell2_id: 6, champion_id: 102, role: 'ADC' } },
]

@matches = create_list(:match, match_data.length)
Expand Down Expand Up @@ -603,7 +603,7 @@
name: 'Hero man',
champion: 'Shyvana',
region: 'NA1',
role: 'DUO_CARRY',
role: 'ADC',
list_order: 'highest',
list_size: 1,
metric: '',
Expand All @@ -614,17 +614,17 @@

before :each do
match_data = [
{ match: { win: true }, ban: { champion_id: 42 }, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, ban: { champion_id: 42 }, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, ban: { champion_id: 42 }, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, ban: { champion_id: 42 }, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, ban: { champion_id: 42 }, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, ban: { champion_id: 45 }, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, ban: { champion_id: 45 }, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: false }, ban: { champion_id: 41 }, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: false }, ban: { champion_id: 41 }, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: false }, ban: { champion_id: 41 }, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: false }, ban: { champion_id: 41 }, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, ban: { champion_id: 42 }, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, ban: { champion_id: 42 }, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, ban: { champion_id: 42 }, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, ban: { champion_id: 42 }, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, ban: { champion_id: 42 }, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, ban: { champion_id: 45 }, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, ban: { champion_id: 45 }, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: false }, ban: { champion_id: 41 }, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: false }, ban: { champion_id: 41 }, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: false }, ban: { champion_id: 41 }, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: false }, ban: { champion_id: 41 }, summoner_performance: { champion_id: 102, role: 'ADC' } },
]

@matches = create_list(:match, match_data.length)
Expand Down Expand Up @@ -922,7 +922,7 @@
name: 'Hero man',
champion: 'Shyvana',
region: 'NA1',
role: 'DUO_CARRY',
role: 'ADC',
list_order: 'highest',
list_size: 2,
metric: '',
Expand All @@ -937,17 +937,17 @@
@incomplete_build = [3089, 3086, 3085, 3083, 2303, 3512]
@partial_build = [3083, 2303, 3512]
match_data = [
{ match: { win: true }, build: @complete_build2, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, build: @complete_build2, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, build: @complete_build, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, build: @complete_build, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, build: @complete_build.reverse, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: false }, build: @incomplete_build, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: false }, build: @incomplete_build, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, build: @partial_build, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, build: @partial_build, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, build: @partial_build, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, build: @partial_build, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' } },
{ match: { win: true }, build: @complete_build2, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, build: @complete_build2, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, build: @complete_build, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, build: @complete_build, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, build: @complete_build.reverse, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: false }, build: @incomplete_build, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: false }, build: @incomplete_build, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, build: @partial_build, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, build: @partial_build, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, build: @partial_build, summoner_performance: { champion_id: 102, role: 'ADC' } },
{ match: { win: true }, build: @partial_build, summoner_performance: { champion_id: 102, role: 'ADC' } },
]
@matches = create_list(:match, match_data.length)
summoner = create(:summoner, name: 'Hero man')
Expand Down Expand Up @@ -1237,7 +1237,7 @@
before :each do
@matches = create_list(:match, 6)
match_data = [
{ match: { win: true }, summoner_performance: { champion_id: 102, role: 'DUO_CARRY' }, opponent: { champion_id: 40 } },
{ match: { win: true }, summoner_performance: { champion_id: 102, role: 'ADC' }, opponent: { champion_id: 40 } },
{ match: { win: false }, summoner_performance: { champion_id: 102, role: 'MIDDLE' }, opponent: { champion_id: 50 } },
{ match: { win: true }, summoner_performance: { champion_id: 102, role: 'MIDDLE' }, opponent: { champion_id: 60 } },
{ match: { win: true }, summoner_performance: { champion_id: 102, role: 'JUNGLE' }, opponent: { champion_id: 40 } },
Expand Down Expand Up @@ -1431,7 +1431,7 @@

context 'with incomplete results' do
before :each do
summoner_params[:role] = 'DUO_CARRY'
summoner_params[:role] = 'ADC'
end

context 'with recency' do
Expand Down Expand Up @@ -1624,7 +1624,7 @@
before :each do
matches = create_list(:match, 5)
match_data = [
{ match: { win: true }, summoner_performance: { champion_id: 18, role: 'DUO_CARRY' } },
{ match: { win: true }, summoner_performance: { champion_id: 18, role: 'ADC' } },
{ match: { win: false }, summoner_performance: { champion_id: 18, role: 'MIDDLE' } },
{ match: { win: true }, summoner_performance: { champion_id: 20, role: 'MIDDLE' } },
{ match: { win: true }, summoner_performance: { champion_id: 20, role: 'JUNGLE' } },
Expand Down Expand Up @@ -2249,7 +2249,7 @@
name: 'Hero man',
region: 'NA1',
champion: 'Tristana',
role: 'DUO_CARRY',
role: 'ADC',
recency: ''
}
end
Expand All @@ -2258,11 +2258,11 @@
@match1 = create(:match)
@match2 = create(:match)
summoner_performance = @match1.summoner_performances.first
summoner_performance.update!(champion_id: 18, role: 'DUO_CARRY')
summoner_performance.update!(champion_id: 18, role: 'ADC')
summoner_performance.summoner.update!(name: 'Hero man')
@match2.summoner_performances.first.update(
champion_id: 18,
role: 'DUO_CARRY',
role: 'ADC',
summoner: summoner_performance.summoner
)
end
Expand Down Expand Up @@ -2366,7 +2366,7 @@

context 'with multiple roles' do
before :each do
@match2.summoner_performances.first.update(role: 'DUO_SUPPORT')
@match2.summoner_performances.first.update(role: 'SUPPORT')
end

it 'should prompt to specify a role' do
Expand All @@ -2384,7 +2384,7 @@
{
name: 'Hero man',
champion: 'Tristana',
role: 'DUO_CARRY',
role: 'ADC',
position_details: 'kills',
region: 'NA1',
recency: '',
Expand All @@ -2396,11 +2396,11 @@
@match1 = create(:match)
@match2 = create(:match)
summoner_performance = @match1.summoner_performances.first
summoner_performance.update!(champion_id: 18, role: 'DUO_CARRY')
summoner_performance.update!(champion_id: 18, role: 'ADC')
summoner_performance.summoner.update!(name: 'Hero man')
@match2.summoner_performances.first.update(
champion_id: 18,
role: 'DUO_CARRY',
role: 'ADC',
summoner: summoner_performance.summoner
)
end
Expand Down Expand Up @@ -2537,7 +2537,7 @@

context 'with multiple roles' do
before :each do
@match2.summoner_performances.first.update(role: 'DUO_SUPPORT')
@match2.summoner_performances.first.update(role: 'SUPPORT')
end

context 'with recency' do
Expand Down

0 comments on commit 5646f8e

Please sign in to comment.