adds consistency to ruby code style

Keep a blank line before and after private
Keep a blank line before and after protected
Remove extra empty line at class body end
Remove extra blank line
Add final newline
Use 2 (not 3) spaces for indentation
Use 2 (not 4) spaces for indentation
Remove space before comma
Add space after comma
Remove trailing whitespaces
Remove unnecessary spacing
Use snake_case for variable names
Do not use then for multi-line if
Remove unused block argument - i
Use the new Ruby 1.9 hash syntax
Remove unused assignment to variable
Indent when as deep as case
Align attributes
Align end with def
This commit is contained in:
rgarcia
2016-11-15 11:18:43 +01:00
parent f24ced329f
commit bb3c4c6399
85 changed files with 215 additions and 182 deletions

View File

@@ -1,6 +1,7 @@
require 'rails_helper'
feature 'Admin banners magement' do
background do
login_as(create(:administrator).user)
end
@@ -124,8 +125,8 @@ feature 'Admin banners magement' do
fill_in 'banner_description', with: 'Edited text'
within('div#js-banner-style') do
expect(page).to have_selector('h2', :text => 'Modified title')
expect(page).to have_selector('h3', :text => 'Edited text')
expect(page).to have_selector('h2', text: 'Modified title')
expect(page).to have_selector('h3', text: 'Edited text')
end
click_button 'Save changes'
@@ -139,13 +140,14 @@ feature 'Admin banners magement' do
end
scenario 'Delete a banner' do
banner1 = create(:banner, title: 'Ugly banner',
description: 'Bad text',
target_url: 'http://www.url.com',
style: 'banner-style.banner-one',
image: 'banner-img.banner-one',
post_started_at: (Time.now + 4.days),
post_ended_at: (Time.now + 10.days))
create(:banner, title: 'Ugly banner',
description: 'Bad text',
target_url: 'http://www.url.com',
style: 'banner-style.banner-one',
image: 'banner-img.banner-one',
post_started_at: (Time.now + 4.days),
post_ended_at: (Time.now + 10.days))
visit admin_root_path
within("#side_menu") do

View File

@@ -98,4 +98,4 @@ feature 'Admin comments' do
expect(current_url).to include('page=2')
end
end
end

View File

@@ -91,4 +91,4 @@ feature 'Admin debates' do
expect(current_url).to include('page=2')
end
end
end

View File

@@ -60,4 +60,5 @@ feature 'Admin feature flags' do
expect(page).to have_link "Spending proposals"
end
end
end

View File

@@ -33,5 +33,5 @@ feature 'Admin managers' do
expect(page).to_not have_content @manager.name
end
end
end
end

View File

@@ -27,4 +27,5 @@ feature 'Admin settings' do
expect(page).to have_content 'Value updated'
end
end

View File

@@ -665,4 +665,4 @@ feature 'Admin spending proposals' do
end
end
end

View File

@@ -956,7 +956,6 @@ feature 'Debates' do
end
end
context 'Suggesting debates' do
scenario 'Shows up to 5 suggestions', :js do
author = create(:user)
@@ -1029,7 +1028,6 @@ feature 'Debates' do
end
end
scenario 'Index include featured debates' do
admin = create(:administrator)
login_as(admin.user)

View File

@@ -198,4 +198,4 @@ feature 'Tags' do
end
end
end

View File

@@ -3,24 +3,24 @@ require 'rails_helper'
feature 'Tracking' do
context 'Custom variable' do
scenario 'Usertype anonymous' do
visit proposals_path
expect(page.html).to include "anonymous"
expect(page.html).to include "anonymous"
end
scenario 'Usertype level_1_user' do
scenario 'Usertype level_1_user' do
create(:geozone)
user = create(:user)
login_as(user)
visit proposals_path
expect(page.html).to include "level_1_user"
end
scenario 'Usertype level_2_user' do
scenario 'Usertype level_2_user' do
create(:geozone)
user = create(:user)
login_as(user)
@@ -36,12 +36,12 @@ feature 'Tracking' do
user = user.reload
fill_in 'sms_confirmation_code', with: user.sms_confirmation_code
click_button 'Send'
expect(page.html).to include "level_2_user"
end
end
end
context 'Tracking events' do
context 'Tracking events' do
scenario 'Verification: start census' do
user = create(:user)
login_as(user)
@@ -67,7 +67,7 @@ feature 'Tracking' do
click_button 'Send'
expect(page.html).to include "data-track-event-category=verification"
expect(page.html).to include "data-track-event-action=start_sms"
expect(page.html).to include "data-track-event-action=start_sms"
end
scenario 'Verification: start sms' do
@@ -81,12 +81,12 @@ feature 'Tracking' do
verify_residence
fill_in 'sms_phone', with: "611111111"
click_button 'Send'
click_button 'Send'
expect(page.html).to include "data-track-event-category=verification"
expect(page.html).to include "data-track-event-action=start_sms"
expect(page.html).to include "data-track-event-action=start_sms"
end
scenario 'Verification: success sms' do
create(:geozone)
user = create(:user)
@@ -95,7 +95,7 @@ feature 'Tracking' do
visit account_path
click_link 'Verify my account'
verify_residence
verify_residence
fill_in 'sms_phone', with: "611111111"
click_button 'Send'
@@ -128,7 +128,7 @@ feature 'Tracking' do
click_link "Send me a letter with the code"
expect(page.html).to include "data-track-event-category=verification"
expect(page.html).to include "data-track-event-action=start_letter"
expect(page.html).to include "data-track-event-action=start_letter"
end
end
end

View File

@@ -52,7 +52,6 @@ feature 'Users' do
uid: '12345',
info: {name: 'manuela', email: 'manuelacarmena@example.com', verified: '1'}} }
scenario 'Sign up when Oauth provider has a verified email' do
OmniAuth.config.add_mock(:twitter, twitter_hash_with_verified_email)
@@ -289,16 +288,16 @@ feature 'Users' do
scenario 'Sign in, admin with password expired' do
user = create(:user, password_changed_at: Time.now - 1.year)
admin = create(:administrator, user: user)
login_as(admin.user)
visit root_path
expect(page).to have_content "Your password is expired"
fill_in 'user_current_password', with: 'judgmentday'
fill_in 'user_password', with: '123456789'
fill_in 'user_password_confirmation', with: '123456789'
click_button 'Change your password'
expect(page).to have_content "Password successfully updated"
@@ -307,37 +306,37 @@ feature 'Users' do
scenario 'Sign in, admin without password expired' do
user = create(:user, password_changed_at: Time.now - 360.days)
admin = create(:administrator, user: user)
login_as(admin.user)
visit root_path
expect(page).to_not have_content "Your password is expired"
expect(page).to_not have_content "Your password is expired"
end
scenario 'Sign in, user with password expired' do
user = create(:user, password_changed_at: Time.now - 1.year)
login_as(user)
visit root_path
expect(page).to_not have_content "Your password is expired"
end
scenario 'Admin with password expired trying to use same password' do
scenario 'Admin with password expired trying to use same password' do
user = create(:user, password_changed_at: Time.now - 1.year, password: '123456789')
admin = create(:administrator, user: user)
login_as(admin.user)
admin = create(:administrator, user: user)
login_as(admin.user)
visit root_path
expect(page).to have_content "Your password is expired"
fill_in 'user_current_password', with: 'judgmentday'
fill_in 'user_password', with: '123456789'
fill_in 'user_password_confirmation', with: '123456789'
click_button 'Change your password'
expect(page).to have_content "must be different than the current password."
end
expect(page).to have_content "Your password is expired"
end
fill_in 'user_current_password', with: 'judgmentday'
fill_in 'user_password', with: '123456789'
fill_in 'user_password_confirmation', with: '123456789'
click_button 'Change your password'
expect(page).to have_content "must be different than the current password."
end
end

View File

@@ -98,4 +98,5 @@ feature 'Verification path' do
expect(page).to have_content 'Your account is already verified'
end
end
end

View File

@@ -85,7 +85,7 @@ describe EmailDigest do
user = create(:user)
proposal_notification = create(:proposal_notification)
notification = create(:notification, notifiable: proposal_notification, user: user, emailed_at: Time.now)
create(:notification, notifiable: proposal_notification, user: user, emailed_at: Time.now)
reset_mailer
email_digest = EmailDigest.new(user)

View File

@@ -651,28 +651,28 @@ describe Proposal do
context "no results" do
it "no words match" do
proposal = create(:proposal, title: 'save world')
create(:proposal, title: 'save world')
results = Proposal.search('destroy planet')
expect(results).to eq([])
end
it "too many typos" do
proposal = create(:proposal, title: 'fantastic')
create(:proposal, title: 'fantastic')
results = Proposal.search('frantac')
expect(results).to eq([])
end
it "too much stemming" do
proposal = create(:proposal, title: 'reloj')
create(:proposal, title: 'reloj')
results = Proposal.search('superrelojimetro')
expect(results).to eq([])
end
it "empty" do
proposal = create(:proposal, title: 'great')
create(:proposal, title: 'great')
results = Proposal.search('')
expect(results).to eq([])

View File

@@ -19,4 +19,4 @@ describe Verification::Sms do
expect(build(:verification_sms, phone: "555; DROP TABLE USERS")).to_not be_valid
end
end
end

View File

@@ -174,7 +174,7 @@ describe SpendingProposal do
by_valuator = SpendingProposal.by_valuator(valuator1.id)
expect(by_valuator.size).to eq(2)
expect(by_valuator.sort).to eq([spending_proposal1,spending_proposal3].sort)
expect(by_valuator.sort).to eq([spending_proposal1, spending_proposal3].sort)
end
end

View File

@@ -9,7 +9,7 @@ RSpec.configure do |config|
config.filter_run :focus
config.run_all_when_everything_filtered = true
config.include Devise::TestHelpers, :type => :controller
config.include Devise::TestHelpers, type: :controller
config.include FactoryGirl::Syntax::Methods
config.include(EmailSpec::Helpers)
config.include(EmailSpec::Matchers)

View File

@@ -159,7 +159,7 @@ module CommonActions
expect(page).to have_selector('.in-favor a', visible: false)
end
def expect_message_you_need_to_sign_in_to_vote_comments
def expect_message_you_need_to_sign_in_to_vote_comments
expect(page).to have_content 'You must Sign in or Sign up to vote'
expect(page).to have_selector('.participation-allowed', visible: false)
expect(page).to have_selector('.participation-not-allowed', visible: true)

View File

@@ -159,4 +159,5 @@ shared_examples_for "verifiable" do
expect(user.verification_letter_sent?).to eq(false)
end
end
end