Fixed Style/StringLiterals RuboCop offense

See:
https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
Bug: T117984

Change-Id: I5388aa3f7c47b9667a03d905f6562dfe6939a70e
This commit is contained in:
Željko Filipin 2015-12-09 17:21:54 +01:00
parent 810506a063
commit c8237daa5b
9 changed files with 73 additions and 79 deletions

View file

@ -16,9 +16,3 @@ Metrics/LineLength:
Style/GlobalVars: Style/GlobalVars:
Exclude: Exclude:
- 'tests/browser/features/step_definitions/mmv_performance_steps.rb' - 'tests/browser/features/step_definitions/mmv_performance_steps.rb'
# Offense count: 79
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/StringLiterals:
Enabled: false

View file

@ -1,4 +1,4 @@
source "https://rubygems.org" source 'https://rubygems.org'
gem "mediawiki_selenium", "~> 1.6.2" gem 'mediawiki_selenium', '~> 1.6.2'
gem "rubocop", "~> 0.35.1", require: false gem 'rubocop', '~> 0.35.1', require: false

View file

@ -1,8 +1,8 @@
# encoding: utf-8 # encoding: utf-8
When /^I open the download dropdown$/ do When /^I open the download dropdown$/ do
step "I click the download icon" step 'I click the download icon'
step "I click the download down arrow icon" step 'I click the download down arrow icon'
end end
When /^I click the download icon$/ do When /^I click the download icon$/ do
@ -25,11 +25,11 @@ end
When /^I click the (.*) download size$/ do |size_option| When /^I click the (.*) download size$/ do |size_option|
on(E2ETestPage) do |page| on(E2ETestPage) do |page|
case size_option case size_option
when "small" when 'small'
@index = 1 @index = 1
when "medium" when 'medium'
@index = 2 @index = 2
when "large" when 'large'
@index = 3 @index = 3
else else
@index = 0 @index = 0

View file

@ -10,7 +10,7 @@ end
When /^I press the browser back button$/ do When /^I press the browser back button$/ do
# $browser.back doesn't work for Safari. This is a workaround for https://code.google.com/p/selenium/issues/detail?id=3771 # $browser.back doesn't work for Safari. This is a workaround for https://code.google.com/p/selenium/issues/detail?id=3771
on(E2ETestPage).execute_script("window.history.back();") on(E2ETestPage).execute_script('window.history.back();')
end end
Then /^the image and metadata of the next image should appear$/ do Then /^the image and metadata of the next image should appear$/ do
@ -31,7 +31,7 @@ end
Then /^the wiki article should be scrolled to the same position as before opening MMV$/ do Then /^the wiki article should be scrolled to the same position as before opening MMV$/ do
on(E2ETestPage) do |page| on(E2ETestPage) do |page|
scroll_difference = page.execute_script("return $(window).scrollTop();") - @article_scroll_top scroll_difference = page.execute_script('return $(window).scrollTop();') - @article_scroll_top
expect(scroll_difference.abs).to be < 2 expect(scroll_difference.abs).to be < 2
end end
end end

View file

@ -33,24 +33,24 @@ When /^I click the disable X icon$/ do
end end
When /^I disable MMV$/ do When /^I disable MMV$/ do
step "I click the options icon" step 'I click the options icon'
step "I click the disable button" step 'I click the disable button'
end end
When /^I reenable MMV$/ do When /^I reenable MMV$/ do
step "I disable MMV" step 'I disable MMV'
step "I click the options icon" step 'I click the options icon'
step "I click the enable button" step 'I click the enable button'
end end
When /^I click the options icon with MMV disabled$/ do When /^I click the options icon with MMV disabled$/ do
step "I disable MMV" step 'I disable MMV'
step "I click the options icon" step 'I click the options icon'
end end
When /^I disable and close MMV$/ do When /^I disable and close MMV$/ do
step "I disable MMV" step 'I disable MMV'
step "I close MMV" step 'I close MMV'
end end
Then /^the disable confirmation should appear$/ do Then /^the disable confirmation should appear$/ do

View file

@ -4,11 +4,11 @@ end
Given /^I visit the Commons page$/ do Given /^I visit the Commons page$/ do
@commons_open_time = Time.now.getutc @commons_open_time = Time.now.getutc
browser.goto "https://commons.wikimedia.org/wiki/File:Sunrise_over_fishing_boats_in_Kerala.jpg" browser.goto 'https://commons.wikimedia.org/wiki/File:Sunrise_over_fishing_boats_in_Kerala.jpg'
end end
Given /^I visit an unrelated Commons page to warm up the browser cache$/ do Given /^I visit an unrelated Commons page to warm up the browser cache$/ do
browser.goto "https://commons.wikimedia.org/wiki/File:Wikimedia_Foundation_2013_All_Hands_Offsite_-_Day_2_-_Photo_16.jpg" browser.goto 'https://commons.wikimedia.org/wiki/File:Wikimedia_Foundation_2013_All_Hands_Offsite_-_Day_2_-_Photo_16.jpg'
end end
Given /^I have a small browser window$/ do Given /^I have a small browser window$/ do
@ -29,18 +29,18 @@ end
Then /^the File: page image is loaded$/ do Then /^the File: page image is loaded$/ do
on(CommonsPage) do |page| on(CommonsPage) do |page|
page.wait_for_image_load ".fullImageLink img" page.wait_for_image_load '.fullImageLink img'
# Has to be a global variable, otherwise it doesn't survive between scenarios # Has to be a global variable, otherwise it doesn't survive between scenarios
$commons_time = Time.now.getutc - @commons_open_time $commons_time = Time.now.getutc - @commons_open_time
page.log_performance type: "file-page", duration: $commons_time * 1000 page.log_performance type: 'file-page', duration: $commons_time * 1000
end end
end end
Then /^the MMV image is loaded in (\d+) percent of the time with a (.*) cache and an? (.*) browser window$/ do |percentage, cache, window_size| Then /^the MMV image is loaded in (\d+) percent of the time with a (.*) cache and an? (.*) browser window$/ do |percentage, cache, window_size|
on(E2ETestPage) do |page| on(E2ETestPage) do |page|
page.wait_for_image_load ".mw-mmv-image img" page.wait_for_image_load '.mw-mmv-image img'
mmv_time = Time.now.getutc - @image_click_time mmv_time = Time.now.getutc - @image_click_time
page.log_performance type: "mmv", duration: mmv_time * 1000, cache: cache, windowSize: window_size page.log_performance type: 'mmv', duration: mmv_time * 1000, cache: cache, windowSize: window_size
expected_time = $commons_time * (percentage.to_f / 100.0) expected_time = $commons_time * (percentage.to_f / 100.0)
expect(mmv_time).to be < expected_time expect(mmv_time).to be < expected_time

View file

@ -6,9 +6,9 @@ Given /^I am at a wiki article with at least two embedded pictures$/ do
end end
Given /^I am viewing an image using MMV$/ do Given /^I am viewing an image using MMV$/ do
step "I am at a wiki article with at least two embedded pictures" step 'I am at a wiki article with at least two embedded pictures'
step "I click on the second image in the article" step 'I click on the second image in the article'
step "the image metadata and the image itself should be there" step 'the image metadata and the image itself should be there'
end end
When /^I click on the first image in the article$/ do When /^I click on the first image in the article$/ do

View file

@ -1,12 +1,12 @@
require "json" require 'json'
class CommonsPage class CommonsPage
include PageObject include PageObject
page_url "File:Sunrise_over_fishing_boats_in_Kerala.jpg" page_url 'File:Sunrise_over_fishing_boats_in_Kerala.jpg'
img(:commons_image, src: /Kerala\.jpg$/) img(:commons_image, src: /Kerala\.jpg$/)
div(:mmv_image_loaded_cucumber, class: "mw-mmv-image-loaded-cucumber") div(:mmv_image_loaded_cucumber, class: 'mw-mmv-image-loaded-cucumber')
def wait_for_image_load(selector) def wait_for_image_load(selector)
browser.execute_script <<-end_script browser.execute_script <<-end_script

View file

@ -1,87 +1,87 @@
class E2ETestPage < CommonsPage class E2ETestPage < CommonsPage
include PageObject include PageObject
page_url "MediaViewerE2ETest" page_url 'MediaViewerE2ETest'
# Tag page elements that we will need. # Tag page elements that we will need.
# First image in lightbox demo page # First image in lightbox demo page
a(:image1_in_article, class: "image", href: /Kerala\.jpg$/) a(:image1_in_article, class: 'image', href: /Kerala\.jpg$/)
a(:image2_in_article, class: "image", href: /Wikimedia_Foundation_2013_All_Hands_Offsite_-_Day_2_-_Photo_24\.jpg$/) a(:image2_in_article, class: 'image', href: /Wikimedia_Foundation_2013_All_Hands_Offsite_-_Day_2_-_Photo_24\.jpg$/)
a(:other_image_in_article, href: /Academy_of_Sciences\.jpg$/) a(:other_image_in_article, href: /Academy_of_Sciences\.jpg$/)
# Black overlay # Black overlay
div(:mmv_overlay, class: "mw-mmv-overlay") div(:mmv_overlay, class: 'mw-mmv-overlay')
# Wrapper div for all mmv elements # Wrapper div for all mmv elements
div(:mmv_wrapper, class: "mw-mmv-wrapper") div(:mmv_wrapper, class: 'mw-mmv-wrapper')
# Wrapper div for image # Wrapper div for image
div(:mmv_image_div, class: "mw-mmv-image") div(:mmv_image_div, class: 'mw-mmv-image')
# Actual image # Actual image
image(:mmv_final_image, class: "mw-mmv-final-image") image(:mmv_final_image, class: 'mw-mmv-final-image')
# Metadata elements # Metadata elements
span(:mmv_metadata_title, class: "mw-mmv-title") span(:mmv_metadata_title, class: 'mw-mmv-title')
a(:mmv_metadata_license, class: "mw-mmv-license") a(:mmv_metadata_license, class: 'mw-mmv-license')
p(:mmv_metadata_credit, class: "mw-mmv-credit") p(:mmv_metadata_credit, class: 'mw-mmv-credit')
span(:mmv_metadata_source, class: "mw-mmv-source") span(:mmv_metadata_source, class: 'mw-mmv-source')
div(:mmv_image_metadata_wrapper, class: "mw-mmv-image-metadata") div(:mmv_image_metadata_wrapper, class: 'mw-mmv-image-metadata')
p(:mmv_image_metadata_desc, class: "mw-mmv-image-desc") p(:mmv_image_metadata_desc, class: 'mw-mmv-image-desc')
ul(:mmv_image_metadata_links_wrapper, class: "mw-mmv-image-links") ul(:mmv_image_metadata_links_wrapper, class: 'mw-mmv-image-links')
a(:mmv_details_page_link, class: "mw-mmv-description-page-button") a(:mmv_details_page_link, class: 'mw-mmv-description-page-button')
# Controls # Controls
div(:mmv_next_button, class: "mw-mmv-next-image") div(:mmv_next_button, class: 'mw-mmv-next-image')
div(:mmv_previous_button, class: "mw-mmv-prev-image") div(:mmv_previous_button, class: 'mw-mmv-prev-image')
div(:mmv_close_button, class: "mw-mmv-close") div(:mmv_close_button, class: 'mw-mmv-close')
div(:mmv_image_loaded_cucumber, class: "mw-mmv-image-loaded-cucumber") div(:mmv_image_loaded_cucumber, class: 'mw-mmv-image-loaded-cucumber')
# Download # Download
div(:mmv_download_icon, class: "mw-mmv-download-button") div(:mmv_download_icon, class: 'mw-mmv-download-button')
div(:mmv_download_menu, class: "mw-mmv-download-dialog") div(:mmv_download_menu, class: 'mw-mmv-download-dialog')
span(:mmv_download_size_label, class: "mw-mmv-download-image-size") span(:mmv_download_size_label, class: 'mw-mmv-download-image-size')
span(:mmv_download_down_arrow_icon, class: "mw-mmv-download-select-menu") span(:mmv_download_down_arrow_icon, class: 'mw-mmv-download-select-menu')
div(:mmv_download_size_menu_container, class: "mw-mmv-download-size") div(:mmv_download_size_menu_container, class: 'mw-mmv-download-size')
div(:mmv_download_size_menu) do |page| div(:mmv_download_size_menu) do |page|
page.mmv_download_size_menu_container_element.div_element(class: "oo-ui-selectWidget") page.mmv_download_size_menu_container_element.div_element(class: 'oo-ui-selectWidget')
end end
divs(:mmv_download_size_options, class: "oo-ui-menuOptionWidget") divs(:mmv_download_size_options, class: 'oo-ui-menuOptionWidget')
a(:mmv_download_link, class: "mw-mmv-download-go-button") a(:mmv_download_link, class: 'mw-mmv-download-go-button')
a(:mmv_download_preview_link, class: "mw-mmv-download-preview-link") a(:mmv_download_preview_link, class: 'mw-mmv-download-preview-link')
div(:mmv_download_attribution_area, class: "mw-mmv-download-attribution") div(:mmv_download_attribution_area, class: 'mw-mmv-download-attribution')
p(:mmv_download_attribution_area_close_icon, class: "mw-mmv-download-attribution-close-button") p(:mmv_download_attribution_area_close_icon, class: 'mw-mmv-download-attribution-close-button')
div(:mmv_download_attribution_area_input_container, class: "mw-mmv-download-attr-input") div(:mmv_download_attribution_area_input_container, class: 'mw-mmv-download-attr-input')
text_field(:mmv_download_attribution_area_input) do |page| text_field(:mmv_download_attribution_area_input) do |page|
page.mmv_download_attribution_area_input_container_element.text_field_element page.mmv_download_attribution_area_input_container_element.text_field_element
end end
# Options # Options
div(:mmv_options_icon, class: "mw-mmv-options-button") div(:mmv_options_icon, class: 'mw-mmv-options-button')
div(:mmv_options_menu_disable, class: "mw-mmv-options-disable") div(:mmv_options_menu_disable, class: 'mw-mmv-options-disable')
div(:mmv_options_menu_enable, class: "mw-mmv-options-enable") div(:mmv_options_menu_enable, class: 'mw-mmv-options-enable')
button(:mmv_options_enable_button) do |page| button(:mmv_options_enable_button) do |page|
page.mmv_options_menu_enable_element.div_element(class: "mw-mmv-options-submit").button_element(class: "mw-mmv-options-submit-button") page.mmv_options_menu_enable_element.div_element(class: 'mw-mmv-options-submit').button_element(class: 'mw-mmv-options-submit-button')
end end
button(:mmv_options_disable_button) do |page| button(:mmv_options_disable_button) do |page|
page.mmv_options_menu_disable_element.div_element(class: "mw-mmv-options-submit").button_element(class: "mw-mmv-options-submit-button") page.mmv_options_menu_disable_element.div_element(class: 'mw-mmv-options-submit').button_element(class: 'mw-mmv-options-submit-button')
end end
button(:mmv_options_enable_cancel_button) do |page| button(:mmv_options_enable_cancel_button) do |page|
page.mmv_options_menu_enable_element.div_element(class: "mw-mmv-options-submit").button_element(class: "mw-mmv-options-cancel-button") page.mmv_options_menu_enable_element.div_element(class: 'mw-mmv-options-submit').button_element(class: 'mw-mmv-options-cancel-button')
end end
button(:mmv_options_disable_cancel_button) do |page| button(:mmv_options_disable_cancel_button) do |page|
page.mmv_options_menu_disable_element.div_element(class: "mw-mmv-options-submit").button_element(class: "mw-mmv-options-cancel-button") page.mmv_options_menu_disable_element.div_element(class: 'mw-mmv-options-submit').button_element(class: 'mw-mmv-options-cancel-button')
end end
div(:mmv_options_disable_confirmation, class: "mw-mmv-disable-confirmation") div(:mmv_options_disable_confirmation, class: 'mw-mmv-disable-confirmation')
div(:mmv_options_disable_x_icon) do |page| div(:mmv_options_disable_x_icon) do |page|
page.mmv_options_disable_confirmation_element.div_element(class: "mw-mmv-confirmation-close") page.mmv_options_disable_confirmation_element.div_element(class: 'mw-mmv-confirmation-close')
end end
div(:mmv_options_enable_confirmation, class: "mw-mmv-enable-confirmation") div(:mmv_options_enable_confirmation, class: 'mw-mmv-enable-confirmation')
div(:mmv_options_enable_x_icon) do |page| div(:mmv_options_enable_x_icon) do |page|
page.mmv_options_enable_confirmation_element.div_element(class: "mw-mmv-confirmation-close") page.mmv_options_enable_confirmation_element.div_element(class: 'mw-mmv-confirmation-close')
end end
end end