diff --git a/Gemfile b/Gemfile index 6cb7c820..17114546 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source 'https://rubygems.org' +# Use css flag icons gem 'flag-icons-rails' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' diff --git a/Gemfile.lock b/Gemfile.lock index 0aba83b9..76a1bf60 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -123,6 +123,8 @@ GEM multipart-post (>= 1.2, < 3) faraday_middleware (0.10.0) faraday (>= 0.7.4, < 0.10) + flag-icons-rails (1.1.2) + sass (~> 3.2) foreman (0.78.0) thor (~> 0.19.1) gherkin (2.12.2) @@ -355,6 +357,7 @@ DEPENDENCIES devise (~> 3.5.1) exception_notification (~> 4.1.1) factory_girl_rails (~> 4.5.0) + flag-icons-rails foreman (~> 0.78.0) gisdatigo google-analytics-rails (~> 0.0.6) @@ -390,4 +393,4 @@ DEPENDENCIES web-console (~> 2.0.0) BUNDLED WITH - 1.11.2 + 1.14.6 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1741e5d1..dfe96f08 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -12,6 +12,7 @@ def t_action(action, model, options={}) t("helpers.submit.#{model.model_name.i18n_key}.#{action}", options) end + # method used to map locale route into flag name def map_locale(locale) mapped_locales = { "en": "us", diff --git a/features/homepage.feature b/features/homepage.feature index df1eab6c..c6d12361 100644 --- a/features/homepage.feature +++ b/features/homepage.feature @@ -39,9 +39,16 @@ Feature: Homepage Then I should see "Entendendo Métricas de Código" When I click the Idioma link And I click the "en" flag + Then I should see "Understanding Code Metrics" Scenario: Correct portuguese plural settings option Given I am at the homepage When I click the Language link And I click the "pt" flag Then I should see "Configurações" + + Scenario: See flags in language dropdown + Given I am at the homepage + When I click the Language link + Then I should see "us" flag + Then I should see "br" flag diff --git a/features/step_definitions/homepage_steps.rb b/features/step_definitions/homepage_steps.rb index 27586879..d1a1c702 100644 --- a/features/step_definitions/homepage_steps.rb +++ b/features/step_definitions/homepage_steps.rb @@ -17,3 +17,11 @@ Then(/^I should see "(.*?)" only "(.*?)" times$/) do |text, times| expect(page).to have_content(text, count: times.to_i) end + +When(/^I click the "(.*?)" flag$/) do |text| + find(:css, "a[href='/#{text}']").click +end + +Then(/^I should see "(.*?)" flag$/) do |flag| + find(:css, "span[class='flag-icon flag-icon-#{flag}']") +end diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 78656921..7a2ae884 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -6,10 +6,6 @@ click_button text end -When(/^I click the "(.*?)" flag$/) do |text| - find(:css, "a[href='/#{text}']").click -end - When(/^I fill the (.+) field with "(.+)"$/) do |field, text| fill_in field, :with => text end