Merge pull request #1446 from sunny-b/master

Enable Style/DotPosition Rubocop cop
This commit is contained in:
Ana María Martínez Gómez 2017-04-07 11:21:34 +02:00 committed by GitHub
commit fd6d0bf39b
25 changed files with 143 additions and 142 deletions

View file

@ -39,6 +39,10 @@ Style/CaseEquality:
Style/ClassAndModuleChildren:
Enabled: true
# Checks the . position in multi-line method calls.
Style/DotPosition:
Enabled: true
# Checks for uses of double negation (!!) to convert something to a boolean value.
Style/DoubleNegation:
Enabled: true

View file

@ -222,13 +222,6 @@ Style/ConditionalAssignment:
Style/Documentation:
Enabled: false
# Offense count: 74
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: leading, trailing
Style/DotPosition:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Style/ElseAlignment:

View file

@ -21,8 +21,8 @@ module Admin
@new_submissions = Event.where('created_at > ?', current_user.last_sign_in_at).count
@active_conferences = Conference.get_active_conferences_for_dashboard # pending or the last two
@deactive_conferences = Conference.
get_conferences_without_active_for_dashboard(@active_conferences) # conferences without active
@deactive_conferences = Conference
.get_conferences_without_active_for_dashboard(@active_conferences) # conferences without active
@conferences = @active_conferences + @deactive_conferences
@recent_users = User.limit(5).order(created_at: :desc)
@ -106,8 +106,8 @@ module Admin
@new_reg = @conference.registrations.where('created_at > ?', current_user.last_sign_in_at).count
@total_submissions = @program.events.count
@new_submissions = @program.events.
where('created_at > ?', current_user.last_sign_in_at).count
@new_submissions = @program.events
.where('created_at > ?', current_user.last_sign_in_at).count
@program_length = @conference.current_program_hours
@new_program_length = @conference.new_program_hours(current_user.last_sign_in_at)
@ -139,8 +139,8 @@ module Admin
@event_type_distribution_confirmed = @conference.event_type_distribution(:confirmed)
@difficulty_levels_distribution = @conference.difficulty_levels_distribution
@difficulty_levels_distribution_confirmed = @conference.
difficulty_levels_distribution(:confirmed)
@difficulty_levels_distribution_confirmed = @conference
.difficulty_levels_distribution(:confirmed)
@tracks_distribution = @conference.tracks_distribution
@tracks_distribution_confirmed = @conference.tracks_distribution(:confirmed)

View file

@ -10,10 +10,10 @@ module Admin
@events_with_requirements = @events.where.not(description: ['', nil])
attended_registrants_ids = @conference.registrations.where(attended: true).pluck(:user_id)
@missing_event_speakers = EventUser.joins(:event).
where('event_role = ? and program_id = ?', 'submitter', @program.id).
where.not(user_id: attended_registrants_ids).
includes(:user, :event)
@missing_event_speakers = EventUser.joins(:event)
.where('event_role = ? and program_id = ?', 'submitter', @program.id)
.where.not(user_id: attended_registrants_ids)
.includes(:user, :event)
end
end
end

View file

@ -108,8 +108,8 @@ class ConferenceRegistrationsController < ApplicationController
end
def registration_params
params.require(:registration).
permit(
params.require(:registration)
.permit(
:conference_id, :arrival, :departure,
:volunteer,
vchoice_ids: [], qanswer_ids: [],

View file

@ -23,12 +23,12 @@ class RegistrationsController < Devise::RegistrationsController
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:account_update) do |u|
u.
permit(:email, :password, :password_confirmation, :current_password, :username, :email_public)
u
.permit(:email, :password, :password_confirmation, :current_password, :username, :email_public)
end
devise_parameter_sanitizer.permit(:sign_up) do |u|
u.
permit(:email, :password, :password_confirmation, :name, :username)
u
.permit(:email, :password, :password_confirmation, :name, :username)
end
end
end

View file

@ -417,10 +417,10 @@ module ApplicationHelper
# Eg: If version.changeset = '{"title"=>[nil, "Premium"], "description"=>[nil, "Premium = Super cool"], "conference_id"=>[nil, 3]}'
# Output will be 'title, description and conference'
def updated_attributes(version)
version.changeset.
reject{ |_, values| values[0].blank? && values[1].blank? }.
keys.map{ |key| key.gsub('_id', '').tr('_', ' ')}.join(', ').
reverse.sub(',', ' dna ').reverse
version.changeset
.reject{ |_, values| values[0].blank? && values[1].blank? }
.keys.map{ |key| key.gsub('_id', '').tr('_', ' ')}.join(', ')
.reverse.sub(',', ' dna ').reverse
end
def link_to_user(user_id)

View file

@ -58,16 +58,20 @@ class Cfp < ActiveRecord::Base
private
def before_end_of_conference
errors.
add(:end_date, "can't be after the conference end date (#{program.conference.end_date})") if program.conference && program.conference.end_date && end_date && (end_date > program.conference.end_date)
if program.conference && program.conference.end_date && end_date && (end_date > program.conference.end_date)
errors
.add(:end_date, "can't be after the conference end date (#{program.conference.end_date})")
end
errors.
add(:start_date, "can't be after the conference end date (#{program.conference.end_date})") if program.conference && program.conference.end_date && start_date && (start_date > program.conference.end_date)
if program.conference && program.conference.end_date && start_date && (start_date > program.conference.end_date)
errors
.add(:start_date, "can't be after the conference end date (#{program.conference.end_date})")
end
end
def start_after_end_date
errors.
add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date
errors
.add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date
end
def conference_id

View file

@ -180,8 +180,8 @@ class Conference < ActiveRecord::Base
if registration_period &&
registration_period.start_date &&
registration_period.end_date
weeks = Date.new(registration_period.start_date.year, 12, 31).
strftime('%W').to_i
weeks = Date.new(registration_period.start_date.year, 12, 31)
.strftime('%W').to_i
result = get_registration_end_week - get_registration_start_week + 1
end
@ -277,9 +277,9 @@ class Conference < ActiveRecord::Base
# ====Returns
# * +hash+ -> user: submissions
def get_top_submitter(limit = 5)
submitter = EventUser.joins(:event).
where('event_role = ? and program_id = ?', 'submitter', Conference.find(id).program.id).
limit(limit).group(:user_id)
submitter = EventUser.joins(:event)
.where('event_role = ? and program_id = ?', 'submitter', Conference.find(id).program.id)
.limit(limit).group(:user_id)
counter = submitter.order('count_all desc').count
Conference.calculate_user_submission_hash(submitter, counter)
end
@ -461,13 +461,13 @@ class Conference < ActiveRecord::Base
# ====Returns
# * +ActiveRecord+
def self.get_active_conferences_for_dashboard
result = Conference.where('start_date > ?', Time.now).
select('id, short_title, color, start_date')
result = Conference.where('start_date > ?', Time.now)
.select('id, short_title, color, start_date')
if result.empty?
result = Conference.
select('id, short_title, color, start_date').limit(2).
order(start_date: :desc)
result = Conference
.select('id, short_title, color, start_date').limit(2)
.order(start_date: :desc)
end
result
end

View file

@ -286,8 +286,8 @@ class Event < ActiveRecord::Base
end
def before_end_of_conference
errors.
add(:created_at, "can't be after the conference end date!") if program.conference && program.conference.end_date &&
errors
.add(:created_at, "can't be after the conference end date!") if program.conference && program.conference.end_date &&
(Date.today > program.conference.end_date)
end

View file

@ -10,15 +10,15 @@ class RegistrationPeriod < ActiveRecord::Base
private
def before_end_of_conference
errors.
add(:start_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && start_date && (start_date > conference.end_date)
errors
.add(:start_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && start_date && (start_date > conference.end_date)
errors.
add(:end_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && end_date && (end_date > conference.end_date)
errors
.add(:end_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && end_date && (end_date > conference.end_date)
end
def start_date_before_end_date
errors.
add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date
errors
.add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date
end
end

View file

@ -56,8 +56,8 @@ describe Admin::ConferencesController do
short_title: nil)
conference.reload
expect(flash[:error]).
to eq("Updating conference failed. Short title can't be blank.")
expect(flash[:error])
.to eq("Updating conference failed. Short title can't be blank.")
expect(conference.title).to eq("#{conference.title}")
expect(conference.short_title).to eq("#{conference.short_title}")
end
@ -67,8 +67,8 @@ describe Admin::ConferencesController do
attributes_for(:conference, title: 'Example Con',
short_title: nil)
expect(flash[:error]).
to eq("Updating conference failed. Short title can't be blank.")
expect(flash[:error])
.to eq("Updating conference failed. Short title can't be blank.")
expect(response).to redirect_to edit_admin_conference_path(
conference.short_title)
end

View file

@ -42,8 +42,8 @@ describe Admin::UsersController do
end
it 'changes @users attributes' do
expect(build(
:user, email: 'email_new@osem.io', id: user.id).email).
to eq('email_new@osem.io')
:user, email: 'email_new@osem.io', id: user.id).email)
.to eq('email_new@osem.io')
end
it 'redirects to the updated user' do
expect(response).to redirect_to admin_users_path

View file

@ -16,8 +16,8 @@ feature Conference do
click_button 'Create Cfp'
expect(flash).
to eq('Creating the call for papers failed. ' +
expect(flash)
.to eq('Creating the call for papers failed. ' +
"Start date can't be blank. End date can't be blank.")
today = Date.today - 1
@ -29,8 +29,8 @@ feature Conference do
click_button 'Create Cfp'
# Validations
expect(flash).
to eq('Call for papers successfully created.')
expect(flash)
.to eq('Call for papers successfully created.')
expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y'))
expect(find('#end_date').text).to eq((today + 6).strftime('%A, %B %-d. %Y'))
@ -49,8 +49,8 @@ feature Conference do
page.execute_script(
"$('#registration-period-start-datepicker').val('')")
click_button 'Update Cfp'
expect(flash).
to eq('Updating call for papers failed. ' +
expect(flash)
.to eq('Updating call for papers failed. ' +
"Start date can't be blank.")
# Fill in date
@ -63,8 +63,8 @@ feature Conference do
click_button 'Update Cfp'
# Validations
expect(flash).
to eq('Call for papers successfully updated.')
expect(flash)
.to eq('Call for papers successfully updated.')
expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y'))
expect(find('#end_date').text).to eq((today + 14).strftime('%A, %B %-d. %Y'))
expect(Cfp.count).to eq(expected_count)

View file

@ -15,17 +15,17 @@ feature Conference do
select('(GMT+01:00) Berlin', from: 'conference[timezone]')
today = Date.today - 1
page.
execute_script("$('#conference-start-datepicker').val('" +
page
.execute_script("$('#conference-start-datepicker').val('" +
"#{today.strftime('%d/%m/%Y')}')")
page.
execute_script("$('#conference-end-datepicker').val('" +
page
.execute_script("$('#conference-end-datepicker').val('" +
"#{(today + 7).strftime('%d/%m/%Y')}')")
click_button 'Create Conference'
expect(flash).
to eq('Conference was successfully created.')
expect(flash)
.to eq('Conference was successfully created.')
expect(Conference.count).to eq(expected_count)
expect(user.has_role? :organizer, Conference.last).to eq(true)
@ -45,23 +45,23 @@ feature Conference do
fill_in 'conference_short_title', with: ''
click_button 'Update Conference'
expect(flash).
to eq("Updating conference failed. Short title can't be blank.")
expect(flash)
.to eq("Updating conference failed. Short title can't be blank.")
fill_in 'conference_title', with: 'New Con'
fill_in 'conference_short_title', with: 'NewCon'
day = Date.today + 10
page.
execute_script("$('#conference-start-datepicker').val('" +
page
.execute_script("$('#conference-start-datepicker').val('" +
"#{day.strftime('%d/%m/%Y')}')")
page.
execute_script("$('#conference-end-datepicker').val('" +
page
.execute_script("$('#conference-end-datepicker').val('" +
"#{(day + 7).strftime('%d/%m/%Y')}')")
click_button 'Update Conference'
expect(flash).
to eq('Conference was successfully updated.')
expect(flash)
.to eq('Conference was successfully updated.')
conference.reload
expect(conference.title).to eq('New Con')

View file

@ -25,8 +25,8 @@ feature Contact do
click_button 'Update Contact'
expect(flash).
to eq('Contact details were successfully updated.')
expect(flash)
.to eq('Contact details were successfully updated.')
contact.reload
expect(contact.email).to eq('example@example.com')
expect(contact.sponsor_email).to eq('sponsor@example.com')

View file

@ -53,39 +53,39 @@ feature EmailSettings do
click_button 'Update Email settings'
expect(flash).
to eq('Email settings have been successfully updated.')
expect(flash)
.to eq('Email settings have been successfully updated.')
expect(find('#email_settings_registration_subject').
value).to eq('Registration subject')
expect(find('#email_settings_registration_body').
value).to eq('Registration email body')
expect(find('#email_settings_registration_subject')
.value).to eq('Registration subject')
expect(find('#email_settings_registration_body')
.value).to eq('Registration email body')
click_link 'Proposal'
expect(find('#email_settings_accepted_subject').
value).to eq('Accepted subject')
expect(find('#email_settings_accepted_body').
value).to eq('Accepted email body')
expect(find('#email_settings_rejected_subject').
value).to eq('Rejected subject')
expect(find('#email_settings_rejected_body').
value).to eq('Rejected email body')
expect(find('#email_settings_confirmed_without_registration_subject').
value).to eq('Confirmed without registration subject')
expect(find('#email_settings_confirmed_without_registration_body').
value).to eq('Confirmed without registration email body')
expect(find('#email_settings_accepted_subject')
.value).to eq('Accepted subject')
expect(find('#email_settings_accepted_body')
.value).to eq('Accepted email body')
expect(find('#email_settings_rejected_subject')
.value).to eq('Rejected subject')
expect(find('#email_settings_rejected_body')
.value).to eq('Rejected email body')
expect(find('#email_settings_confirmed_without_registration_subject')
.value).to eq('Confirmed without registration subject')
expect(find('#email_settings_confirmed_without_registration_body')
.value).to eq('Confirmed without registration email body')
click_link 'Update Notifications'
expect(find('#email_settings_conference_dates_updated_subject').
value).to eq('Updated conference dates subject')
expect(find('#email_settings_conference_dates_updated_body').
value).to eq('Updated conference dates email template')
expect(find('#email_settings_conference_registration_dates_updated_subject').
value).to eq('Updated conference registration dates subject')
expect(find('#email_settings_conference_registration_dates_updated_body').
value).to eq('Updated conference registration dates template')
expect(find('#email_settings_venue_updated_subject').
value).to eq('Updated conference venue subject')
expect(find('#email_settings_venue_updated_body').
value).to eq('Updated conference venue template')
expect(find('#email_settings_conference_dates_updated_subject')
.value).to eq('Updated conference dates subject')
expect(find('#email_settings_conference_dates_updated_body')
.value).to eq('Updated conference dates email template')
expect(find('#email_settings_conference_registration_dates_updated_subject')
.value).to eq('Updated conference registration dates subject')
expect(find('#email_settings_conference_registration_dates_updated_body')
.value).to eq('Updated conference registration dates template')
expect(find('#email_settings_venue_updated_subject')
.value).to eq('Updated conference venue subject')
expect(find('#email_settings_venue_updated_body')
.value).to eq('Updated conference venue template')
expect(EmailSettings.count).to eq(expected_count)

View file

@ -22,8 +22,8 @@ feature Program do
click_button 'Update Program'
# Validations
expect(flash).
to eq('The program was successfully updated.')
expect(flash)
.to eq('The program was successfully updated.')
expect(find('#rating').text).to eq('4')
end
end

View file

@ -131,8 +131,8 @@ feature Event do
expect(page.has_content?('Example Proposal')).to be true
expect(@event.state).to eq('unconfirmed')
click_link "confirm_proposal_#{@event.id}"
expect(flash).
to eq('The proposal was confirmed. Please register to attend the conference.')
expect(flash)
.to eq('The proposal was confirmed. Please register to attend the conference.')
expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
@event.reload
expect(@event.state).to eq('confirmed')

View file

@ -16,15 +16,15 @@ feature RegistrationPeriod do
click_link 'New Registration Period'
click_button 'Save Registration Period'
expect(flash).
to eq('An error prohibited the Registration Period from being saved: ' \
expect(flash)
.to eq('An error prohibited the Registration Period from being saved: ' \
"Start date can't be blank. End date can't be blank.")
page.
execute_script("$('#registration-period-start-datepicker').val('" +
page
.execute_script("$('#registration-period-start-datepicker').val('" +
"#{Date.today.strftime('%d/%m/%Y')}')")
page.
execute_script("$('#registration-period-end-datepicker').val('" +
page
.execute_script("$('#registration-period-end-datepicker').val('" +
"#{(Date.today + 5).strftime('%d/%m/%Y')}')")
click_button 'Save Registration Period'

View file

@ -24,8 +24,8 @@ feature Conference do
with: 'Lorem ipsum dolor sit amet, consetetur' \
'sadipscing elitr, sed diam nonumy eirmod tempor'
click_button 'Create Venue'
expect(flash).
to eq('Venue was successfully created.')
expect(flash)
.to eq('Venue was successfully created.')
venue = Conference.find(conference.id).venue
expect(venue.name).to eq('Example University')
expect(venue.street).to eq('Example Street 42')
@ -35,14 +35,14 @@ feature Conference do
# edit the venue
click_link 'Edit Venue'
expect(page.find("//*[@id='venue_submit_action']").
text).to eq('Update Venue')
expect(page.find("//*[@id='venue_submit_action']")
.text).to eq('Update Venue')
fill_in 'venue_name', with: 'Example University new'
fill_in 'venue_website', with: 'www.example.com new'
fill_in 'venue_description', with: 'new'
click_button 'Update Venue'
expect(flash).
to eq('Venue was successfully updated.')
expect(flash)
.to eq('Venue was successfully updated.')
venue.reload
expect(venue.name).to eq('Example University new')
expect(venue.website).to eq('www.example.com new')

View file

@ -27,8 +27,8 @@ feature Conference do
# find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea').
# set('Example Person')
click_button 'Update Conference'
expect(flash).
to eq('Volunteering options were successfully updated.')
expect(flash)
.to eq('Volunteering options were successfully updated.')
# # Validations
# expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)').
@ -73,8 +73,8 @@ feature Conference do
# find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea').
# set('Example Person')
click_button 'Update Conference'
expect(flash).
to eq('Volunteering options were successfully updated.')
expect(flash)
.to eq('Volunteering options were successfully updated.')
# Add vposition
check('Use vpositions')
@ -90,8 +90,8 @@ feature Conference do
# "[id$='_vday_ids']").
# find(:option, "#{Date.today.strftime}").select_option
click_button 'Update Conference'
expect(flash).
to eq('Volunteering options were successfully updated.')
expect(flash)
.to eq('Volunteering options were successfully updated.')
# Validations
# expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\

View file

@ -50,11 +50,11 @@ describe ApplicationHelper, type: :helper do
end
it 'should return HTML for header markdown' do
expect(Redcarpet::Markdown).to receive(:new).
with(Redcarpet::Render::HTML, autolink: true,
space_after_headers: true,
no_intra_emphasis: true).
and_call_original
expect(Redcarpet::Markdown).to receive(:new)
.with(Redcarpet::Render::HTML, autolink: true,
space_after_headers: true,
no_intra_emphasis: true)
.and_call_original
expect(markdown('# this is my header')).to eq "<h1>this is my header</h1>\n"
end

View file

@ -743,8 +743,8 @@ describe Conference do
c = create(:conference, start_date: Time.now - 1.year, end_date: Time.now - 360.days)
result = [a, b, c]
expect(Conference.get_conferences_without_active_for_dashboard([subject])).
to match_array(result)
expect(Conference.get_conferences_without_active_for_dashboard([subject]))
.to match_array(result)
end
it 'returns all conferences if there are no active conferences' do

View file

@ -24,6 +24,6 @@ def mock_commercial_request
author_url: 'https://www.youtube.com/user/Confreaks',
height: 344
}
WebMock.stub_request(:get, /.*youtube.*/).
to_return(status: 200, body: response.to_json, headers: {})
WebMock.stub_request(:get, /.*youtube.*/)
.to_return(status: 200, body: response.to_json, headers: {})
end