diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5652fdabe..64c4ced36 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -23,9 +23,3 @@ Style/Documentation: Style/GlobalVars: Enabled: false -# Offense count: 46 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/StringLiterals: - Enabled: false - diff --git a/Gemfile b/Gemfile index 977fd628c..abeac307c 100755 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,10 @@ # ruby=ruby-2.1.1 # ruby-gemset=Echo -source "https://rubygems.org" +source 'https://rubygems.org' -gem "chunky_png" -gem "csscss" -gem "mediawiki_api" -gem "mediawiki_selenium" -gem "rubocop", require: false +gem 'chunky_png' +gem 'csscss' +gem 'mediawiki_api' +gem 'mediawiki_selenium' +gem 'rubocop', require: false diff --git a/tests/browser/features/step_definitions/common_steps.rb b/tests/browser/features/step_definitions/common_steps.rb index b7c6264ee..ff8709493 100644 --- a/tests/browser/features/step_definitions/common_steps.rb +++ b/tests/browser/features/step_definitions/common_steps.rb @@ -7,12 +7,12 @@ def get_session_username end def get_session_username_b - "EchoUser" + 'EchoUser' end Given(/^I am logged in as the user "(.*?)"$/) do |username| step 'the user "' + username + '" exists' - visit(LoginPage).login_with(username, ENV["MEDIAWIKI_PASSWORD"]) + visit(LoginPage).login_with(username, ENV['MEDIAWIKI_PASSWORD']) end # Note Echo redefines this so that the user is unique to the current browser @@ -22,7 +22,7 @@ Given(/^I am logged in my non-shared account$/) do end Given(/^I am on the "(.+)" page$/) do |title| - on(APIPage).create title, "Test is used by Selenium web driver" + on(APIPage).create title, 'Test is used by Selenium web driver' visit(ArticlePage, using_params: { article_name: title }) end @@ -35,27 +35,27 @@ end Given(/^my user rights get changed$/) do @username = get_new_username client = on(APIPage).client - client.log_in(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"]) - resp = client.query(action: "query", list: "users", ususers: @username, ustoken: 'userrights') + client.log_in(ENV['MEDIAWIKI_USER'], ENV['MEDIAWIKI_PASSWORD']) + resp = client.query(action: 'query', list: 'users', ususers: @username, ustoken: 'userrights') data = resp.data - @token = data["users"][0]["userrightstoken"] - client.action('userrights', token_type: false, token: @token, add: "bot", user: @username) + @token = data['users'][0]['userrightstoken'] + client.action('userrights', token_type: false, token: @token, add: 'bot', user: @username) end Given(/^the user "(.*?)" exists$/) do |username| - on(APIPage).client.log_in(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"]) + on(APIPage).client.log_in(ENV['MEDIAWIKI_USER'], ENV['MEDIAWIKI_PASSWORD']) begin - on(APIPage).client.create_account(username, ENV["MEDIAWIKI_PASSWORD"]) - puts "Successfully created user " + username + on(APIPage).client.create_account(username, ENV['MEDIAWIKI_PASSWORD']) + puts 'Successfully created user ' + username rescue MediawikiApi::ApiError puts 'Assuming in step that user ' + username + ' already exists since was unable to create.' end end Then(/^I am on the Special Notifications page$/) do - expect(@browser.url).to match "Special:Notifications" + expect(@browser.url).to match 'Special:Notifications' end Then(/^I see the first heading on the page says Notifications$/) do - expect(on(ArticlePage).first_heading_span).to match "Notifications" + expect(on(ArticlePage).first_heading_span).to match 'Notifications' end diff --git a/tests/browser/features/step_definitions/messages_steps.rb b/tests/browser/features/step_definitions/messages_steps.rb index eaa8646e5..0c85bafc7 100644 --- a/tests/browser/features/step_definitions/messages_steps.rb +++ b/tests/browser/features/step_definitions/messages_steps.rb @@ -6,7 +6,7 @@ Given(/^I have a Flow message that triggers an alert notification$/) do client = on(APIPage).client username = get_session_username_b step 'the user "' + username + '" exists' - client.log_in(username, ENV["MEDIAWIKI_PASSWORD"]) + client.log_in(username, ENV['MEDIAWIKI_PASSWORD']) client.action('flow', token_type: 'edit', submodule: 'new-topic', page: 'Talk:Flow QA', nttopic: 'Mention #1', ntcontent: '[[User:' + get_session_username + ']] I wanted to say hello.') end diff --git a/tests/browser/features/step_definitions/notifications_steps.rb b/tests/browser/features/step_definitions/notifications_steps.rb index 34b2b4c02..d61f95b51 100644 --- a/tests/browser/features/step_definitions/notifications_steps.rb +++ b/tests/browser/features/step_definitions/notifications_steps.rb @@ -1,13 +1,13 @@ def make_page_with_user(title, text, username) client = on(APIPage).client - client.log_in(username, ENV["MEDIAWIKI_PASSWORD"]) + client.log_in(username, ENV['MEDIAWIKI_PASSWORD']) client.create_page(title, text) end def clear_notifications(username) client = on(APIPage).client step 'the user "' + username + '" exists' - client.log_in(username, ENV["MEDIAWIKI_PASSWORD"]) + client.log_in(username, ENV['MEDIAWIKI_PASSWORD']) client.action('echomarkread', token_type: 'edit', all: '1') end @@ -30,19 +30,19 @@ end Given(/^another user has linked to a page I created from another page$/) do title = 'Selenium Echo link test ' + @random_string - make_page_with_user_a(title, "Selenium test page. Feel free to delete me.") + make_page_with_user_a(title, 'Selenium test page. Feel free to delete me.') title2 = title + ' ' + @random_string - make_page_with_user_b(title2, "I am linking to [[" + title + "]].") + make_page_with_user_b(title2, 'I am linking to [[' + title + ']].') end Given(/^another user writes on my talk page$/) do - make_page_with_user_b("User talk:" + get_session_username, + make_page_with_user_b('User talk:' + get_session_username, "== Barnstar ==\nHello Selenium, here is a barnstar for all your testing! " + @random_string + "~~~~\n") end Given(/^another user @s me on "(.*?)"$/) do |title| username = get_session_username.sub('_', ' ') - text = "@" + username + " Cho cho cho. ~~~~" + text = '@' + username + ' Cho cho cho. ~~~~' make_page_with_user_b(title, text) end @@ -73,7 +73,7 @@ Given(/^I am logged in with no notifications$/) do client = on(APIPage).client username = get_session_username step 'the user "' + username + '" exists' - client.log_in(username, ENV["MEDIAWIKI_PASSWORD"]) + client.log_in(username, ENV['MEDIAWIKI_PASSWORD']) client.action('echomarkread', token_type: 'edit', all: '1') step 'I am logged in my non-shared account' @@ -81,9 +81,9 @@ Given(/^I am logged in with no notifications$/) do end Then(/^I have no new notifications$/) do - expect(on(ArticlePage).flyout_link_element.when_present.class_name).not_to match "mw-echo-unread-notifications" + expect(on(ArticlePage).flyout_link_element.when_present.class_name).not_to match 'mw-echo-unread-notifications' end Then(/^I have new notifications$/) do - expect(on(ArticlePage).flyout_link_element.when_present.class_name).to match "mw-echo-unread-notifications" + expect(on(ArticlePage).flyout_link_element.when_present.class_name).to match 'mw-echo-unread-notifications' end diff --git a/tests/browser/features/support/env.rb b/tests/browser/features/support/env.rb index e68b5f388..cdbe1a440 100644 --- a/tests/browser/features/support/env.rb +++ b/tests/browser/features/support/env.rb @@ -1,5 +1,5 @@ -require "rubygems" -require "bundler/setup" +require 'rubygems' +require 'bundler/setup' Bundler.require diff --git a/tests/browser/features/support/hooks.rb b/tests/browser/features/support/hooks.rb index 5ab6259d9..7da02d584 100644 --- a/tests/browser/features/support/hooks.rb +++ b/tests/browser/features/support/hooks.rb @@ -1,3 +1,3 @@ # Allow running of bundle exec cucumber --dry-run -f stepdefs -require "mediawiki_selenium" +require 'mediawiki_selenium' require 'page-object' diff --git a/tests/browser/features/support/pages/article_page.rb b/tests/browser/features/support/pages/article_page.rb index 35675cea0..5ad1527b3 100644 --- a/tests/browser/features/support/pages/article_page.rb +++ b/tests/browser/features/support/pages/article_page.rb @@ -1,15 +1,15 @@ class ArticlePage include PageObject include URL - page_url URL.url("<%=params[:article_name]%><%=params[:hash]%>") + page_url URL.url('<%=params[:article_name]%><%=params[:hash]%>') - span(:first_heading_span, css: "#firstHeading > span:nth-child(1)") - li(:flyout_link_container, css: "#pt-notifications") - a(:flyout_link, css: "#pt-notifications a") - div(:flyout, css: ".mw-echo-overlay") + span(:first_heading_span, css: '#firstHeading > span:nth-child(1)') + li(:flyout_link_container, css: '#pt-notifications') + a(:flyout_link, css: '#pt-notifications a') + div(:flyout, css: '.mw-echo-overlay') # Overlay header - a(:alert_tab_link, css: ".mw-echo-overlay-title ul li a", index: 1) - button(:mark_as_read, css: ".mw-echo-notifications > button") - a(:messages_view_link, css: ".mw-ui-active") + a(:alert_tab_link, css: '.mw-echo-overlay-title ul li a', index: 1) + button(:mark_as_read, css: '.mw-echo-notifications > button') + a(:messages_view_link, css: '.mw-ui-active') end