From e82bcea83ebb385b03c127bf91fc62dd1b09da31 Mon Sep 17 00:00:00 2001 From: Travis Grathwell Date: Thu, 7 Jan 2016 22:24:05 -0800 Subject: [PATCH] Add a little more classiness to OmniauthProviders Additional style shenanigans + .rubocop.yml --- .rubocop.yml | 199 ++++++++++++++++++ app/controllers/checkins_controller.rb | 2 +- app/controllers/rsvps_controller.rb | 4 +- app/helpers/events_helper.rb | 20 +- app/jobs/reminder_sender.rb | 4 +- app/jobs/survey_sender.rb | 2 +- app/mailers/base_mailer.rb | 2 +- app/models/course.rb | 3 +- app/models/dietary_restriction.rb | 2 +- app/models/event.rb | 10 +- app/models/location.rb | 2 +- app/services/omniauth_providers.rb | 89 ++++---- .../20140816220446_add_github_to_profile.rb | 2 +- db/migrate/20140831221929_fix_column_name.rb | 2 +- ...151207004629_seed_chapters_from_regions.rb | 1 - db/seeds.rb | 8 +- lib/tasks/db.rake | 4 +- spec/controllers/events_controller_spec.rb | 12 +- .../controllers/volunteers_controller_spec.rb | 2 +- spec/features/event_email_request_spec.rb | 4 +- spec/features/event_rsvp_request_spec.rb | 2 +- spec/features/locations_request_spec.rb | 52 ++--- spec/features/new_event_request_spec.rb | 6 +- spec/helpers/events_helper_spec.rb | 6 +- spec/jobs/reminder_sender_spec.rb | 2 +- spec/mailers/mailer_previews_spec.rb | 2 +- spec/models/location_spec.rb | 4 +- spec/seeds/seeds_spec.rb | 14 +- 28 files changed, 336 insertions(+), 126 deletions(-) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 000000000..1ad46baef --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,199 @@ +Lint/BlockAlignment: + Exclude: + - 'lib/tasks/db.rake' + +Lint/EndAlignment: + Enabled: false + +Lint/ShadowingOuterLocalVariable: + Enabled: false + +Lint/UnusedBlockArgument: + Enabled: false + +Lint/UnusedMethodArgument: + Enabled: false + +Lint/UselessAssignment: + Enabled: false + +Metrics/AbcSize: + Max: 160 + +Metrics/ClassLength: + Max: 500 + +Metrics/CyclomaticComplexity: + Max: 11 + +Metrics/LineLength: + Enabled: false + +Metrics/MethodLength: + Enabled: false + +Metrics/ModuleLength: + Enabled: false + +Metrics/PerceivedComplexity: + Max: 12 + +Performance/Count: + Enabled: false + +Performance/Detect: + Enabled: false + +Performance/StringReplacement: + Enabled: false + +Style/AccessorMethodName: + Enabled: false + +Style/AlignArray: + Enabled: false + +Style/AlignHash: + Enabled: false + +Style/AlignParameters: + Enabled: false + +Style/BlockDelimiters: + Enabled: false + +Style/BlockEndNewline: + Enabled: false + +Style/BracesAroundHashParameters: + Enabled: false + +Style/CaseIndentation: + Enabled: false + +Style/ClassAndModuleChildren: + Enabled: false + +Style/ClosingParenthesisIndentation: + Enabled: false + +Style/Documentation: + Enabled: false + +Style/DotPosition: + Enabled: false + +Style/DoubleNegation: + Enabled: false + +Style/ElseAlignment: + Enabled: false + +Style/EmptyLines: + Enabled: false + +Style/EmptyLinesAroundBlockBody: + Enabled: false + +Style/EmptyLinesAroundClassBody: + Enabled: false + +Style/EmptyLinesAroundMethodBody: + Enabled: false + +Style/EmptyLinesAroundModuleBody: + Enabled: false + +Style/ExtraSpacing: + Exclude: + - 'bin/setup' + - 'config.ru' + - 'db/migrate/20131210054655_init_schema.rb' + - 'db/schema.rb' + +Style/GuardClause: + Enabled: false + +Style/IfUnlessModifier: + Enabled: false + +Style/IndentationWidth: + Enabled: false + +Style/IndentHash: + EnforcedStyle: consistent + +Style/Lambda: + Enabled: false + +Style/LeadingCommentSpace: + Enabled: false + +Style/MethodDefParentheses: + Enabled: false + +Style/MultilineBlockLayout: + Enabled: false + +Style/MultilineOperationIndentation: + Enabled: false + +Style/NumericLiterals: + MinDigits: 15 + +Style/ParallelAssignment: + Enabled: false + +Style/PredicateName: + Enabled: false + +Style/RedundantReturn: + Enabled: false + +Style/SelfAssignment: + Enabled: false + +Style/SignalException: + Enabled: false + +Style/SpaceAroundEqualsInParameterDefault: + Enabled: false + +Style/SpaceAroundOperators: + Enabled: false + +Style/SpaceBeforeBlockBraces: + Enabled: false + +Style/SpaceInsideBlockBraces: + Enabled: false + +Style/SpaceInsideBrackets: + Enabled: false + +Style/SpaceInsideHashLiteralBraces: + Enabled: false + +Style/SpaceInsideParens: + Enabled: false + +Style/SingleSpaceBeforeFirstArg: + Enabled: false + +Style/SpecialGlobalVars: + Enabled: false + +Style/StringLiterals: + Enabled: false + +Style/TrailingBlankLines: + Enabled: false + +Style/TrailingComma: + Enabled: false + +Style/TrailingWhitespace: + Enabled: false + +Style/WordArray: + MinSize: 3 diff --git a/app/controllers/checkins_controller.rb b/app/controllers/checkins_controller.rb index 3fd10e076..4ce81056e 100644 --- a/app/controllers/checkins_controller.rb +++ b/app/controllers/checkins_controller.rb @@ -6,7 +6,7 @@ class CheckinsController < ApplicationController def index @rsvp_sessions = @session.rsvp_sessions.joins( - rsvp: :bridgetroll_user + rsvp: :bridgetroll_user ).includes([rsvp: :user]).order('users.first_name asc, users.last_name asc, users.email asc') respond_to do |format| format.html { @checkin_counts = @event.checkin_counts } diff --git a/app/controllers/rsvps_controller.rb b/app/controllers/rsvps_controller.rb index a1834a7d8..bdfb30896 100644 --- a/app/controllers/rsvps_controller.rb +++ b/app/controllers/rsvps_controller.rb @@ -63,7 +63,7 @@ def edit end def update - set_dietary_restrictions(@rsvp, params[:dietary_restrictions]) + set_dietary_restrictions(@rsvp, params[:dietary_restrictions]) if @rsvp.update_attributes(rsvp_params) apply_other_changes_from_params @@ -103,7 +103,7 @@ def destroy protected def redirect_if_event_closed - if !@event.open? + unless @event.open? flash[:error] = "Sorry. This event is closed!" redirect_to @event end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index b38739aba..9c6536162 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -2,16 +2,16 @@ module EventsHelper def get_volunteer_skills(volunteer_rsvp) profile = volunteer_rsvp.user.profile @skills = [] - @skills << 'Teaching' if(volunteer_rsvp.teaching) - @skills << 'TA-ing' if(volunteer_rsvp.taing) - @skills << 'Childcare' if(profile.childcaring) - @skills << 'Writing' if(profile.writing) - @skills << 'Outreach' if(profile.outreach) - @skills << 'Designing' if(profile.designing) - @skills << 'Mentoring' if(profile.mentoring) - @skills << 'Mac OS X' if(profile.macosx) - @skills << 'Windows' if(profile.windows) - @skills << 'Linux' if(profile.linux) + @skills << 'Teaching' if volunteer_rsvp.teaching + @skills << 'TA-ing' if volunteer_rsvp.taing + @skills << 'Childcare' if profile.childcaring + @skills << 'Writing' if profile.writing + @skills << 'Outreach' if profile.outreach + @skills << 'Designing' if profile.designing + @skills << 'Mentoring' if profile.mentoring + @skills << 'Mac OS X' if profile.macosx + @skills << 'Windows' if profile.windows + @skills << 'Linux' if profile.linux @skills.join(', ') end diff --git a/app/jobs/reminder_sender.rb b/app/jobs/reminder_sender.rb index c06c7d565..58c5069cf 100644 --- a/app/jobs/reminder_sender.rb +++ b/app/jobs/reminder_sender.rb @@ -7,12 +7,12 @@ def self.send_all_reminders def self.remind_attendees_for_event(event) event.event_sessions.where(volunteers_only: true).each do |event_session| - self.remind_attendees_for_session(event_session) + remind_attendees_for_session(event_session) end first_everybody_session = event.event_sessions.find_by(volunteers_only: false) return unless first_everybody_session - return unless first_everybody_session.starts_at < Time.zone.now + 3.days + return unless first_everybody_session.starts_at < Time.zone.now + 3.days due_reminders = event.rsvps.confirmed.where(reminded_at: nil) puts "Sending #{due_reminders.count} reminders for #{event.title}..." unless Rails.env.test? diff --git a/app/jobs/survey_sender.rb b/app/jobs/survey_sender.rb index 83945f051..01c5b6412 100644 --- a/app/jobs/survey_sender.rb +++ b/app/jobs/survey_sender.rb @@ -5,7 +5,7 @@ def self.send_all_surveys Event.where('ends_at > ?', FIRST_AUTO_SEND_DATE) .where('ends_at < ?', 1.day.ago) .where('survey_sent_at IS NULL').each do |event| - self.send_surveys(event) + send_surveys(event) end end diff --git a/app/mailers/base_mailer.rb b/app/mailers/base_mailer.rb index a97af2a6e..b06aae0ce 100644 --- a/app/mailers/base_mailer.rb +++ b/app/mailers/base_mailer.rb @@ -9,7 +9,7 @@ def set_recipients(recipients, cc = nil) # away from Sendgrid. # http://sendgrid.com/docs/API_Reference/SMTP_API/ - recipients += cc unless cc == nil + recipients += cc unless cc.nil? headers['X-SMTPAPI'] = { to: recipients diff --git a/app/models/course.rb b/app/models/course.rb index fc221e9bd..dd6672785 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -320,7 +320,8 @@ class Course < ActiveHash::Base id: 8, name: 'BWAG Go Portugues', title: 'Building Web Apps With Go - Em Portugues', - description: "Se você está lendo isto então você está prestes a embarcar em uma jornada de iniciante a pro. Sério! Programação web em Go é tão divertido e fácil que você nem vai perceber quanta informação você está aprendendo ao longo do curso. Todo o material do curso está aqui: https://gobridge.gitbooks.io/building-web-apps-with-go/content/pt-br/index.html.", levels: [ + description: "Se você está lendo isto então você está prestes a embarcar em uma jornada de iniciante a pro. Sério! Programação web em Go é tão divertido e fácil que você nem vai perceber quanta informação você está aprendendo ao longo do curso. Todo o material do curso está aqui: https://gobridge.gitbooks.io/building-web-apps-with-go/content/pt-br/index.html.", + levels: [ { level: 2, color: 'green', diff --git a/app/models/dietary_restriction.rb b/app/models/dietary_restriction.rb index 8660b2cfc..d5ede122e 100644 --- a/app/models/dietary_restriction.rb +++ b/app/models/dietary_restriction.rb @@ -1,7 +1,7 @@ class DietaryRestriction < ActiveRecord::Base belongs_to :rsvp - DIETS = %w{ vegetarian vegan gluten-free dairy-free } + DIETS = %w(vegetarian vegan gluten-free dairy-free) validates_uniqueness_of :restriction, {scope: :rsvp_id} diff --git a/app/models/event.rb b/app/models/event.rb index b5230dbdc..ee6b62f32 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -26,7 +26,7 @@ class Event < ActiveRecord::Base has_many :sections, dependent: :destroy has_many :event_emails, dependent: :destroy - has_many :attendee_rsvps, -> { where(role_id: Role.attendee_role_ids, waitlist_position: nil) }, class_name: 'Rsvp', inverse_of: :event + has_many :attendee_rsvps, -> { where(role_id: Role.attendee_role_ids, waitlist_position: nil) }, class_name: 'Rsvp', inverse_of: :event has_many :student_rsvps, -> { where(role_id: Role::STUDENT.id, waitlist_position: nil) }, class_name: 'Rsvp', inverse_of: :event has_many :student_waitlist_rsvps, -> { where("role_id = #{Role::STUDENT.id} AND waitlist_position IS NOT NULL").order(:waitlist_position) }, class_name: 'Rsvp', inverse_of: :event @@ -91,12 +91,12 @@ def historical? def close_rsvps self.open = false - self.save + save end def reopen_rsvps self.open = true - self.save + save end def closed? @@ -189,7 +189,7 @@ def self.drafted_by(user) end def self.published_or_organized_by(user = nil) - return self.published unless user + return published unless user if user.admin? where(spam: false) @@ -227,7 +227,7 @@ def organizers_with_legacy end def rsvp_for_user(user) - self.rsvps.find_by_user_id(user.id) + rsvps.find_by_user_id(user.id) end def no_rsvp?(user) diff --git a/app/models/location.rb b/app/models/location.rb index 9813439c7..a92b8bff4 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -12,7 +12,7 @@ class Location < ActiveRecord::Base end def full_address - "#{self.address_1}, #{self.city}, #{self.state}, #{self.zip}" + "#{address_1}, #{city}, #{state}, #{zip}" end def name_with_region diff --git a/app/services/omniauth_providers.rb b/app/services/omniauth_providers.rb index 0b0c6715d..e7d6ac9eb 100644 --- a/app/services/omniauth_providers.rb +++ b/app/services/omniauth_providers.rb @@ -30,7 +30,7 @@ def self.provider_data end def self.provider_count - self.provider_data.count + provider_data.count end def self.finish_auth_for(authentication) @@ -40,21 +40,22 @@ def self.finish_auth_for(authentication) end def self.provider_data_for(provider) - self.provider_data.find { |data| data[:key] == provider.to_sym } + provider_data.find { |data| data[:key] == provider.to_sym } end def self.user_attributes_from_omniauth(omniauth) + attribute_generator = OmniauthAttributeGenerator.new(omniauth) case omniauth['provider'] when 'facebook' - self.facebook_omniauth_attributes(omniauth) + attribute_generator.facebook when 'twitter' - self.twitter_omniauth_attributes(omniauth) + attribute_generator.twitter when 'github' - self.github_omniauth_attributes(omniauth) + attribute_generator.github when 'meetup' - self.meetup_omniauth_attributes(omniauth) + attribute_generator.meetup when 'google_oauth2' - self.google_oauth2_omniauth_attributes(omniauth) + attribute_generator.google_oauth2 else raise 'Unknown Provider' end @@ -62,43 +63,53 @@ def self.user_attributes_from_omniauth(omniauth) private - def self.split_name(full_name) - return {} if full_name.blank? + class OmniauthAttributeGenerator + attr_reader :omniauth - components = full_name.split(' ') - { - first_name: components[0], - last_name: components[1..-1].join(' ') - } - end + def initialize(omniauth) + @omniauth = omniauth + end - def self.facebook_omniauth_attributes(omniauth) - { - email: omniauth['info']['email'], - first_name: omniauth['info']['first_name'], - last_name: omniauth['info']['last_name'] - } - end + def facebook + { + email: omniauth['info']['email'], + first_name: omniauth['info']['first_name'], + last_name: omniauth['info']['last_name'] + } + end - def self.twitter_omniauth_attributes(omniauth) - self.split_name(omniauth['info']['name']) - end + def twitter + split_name(omniauth['info']['name']) + end - def self.github_omniauth_attributes(omniauth) - self.split_name(omniauth['info']['name']).merge( - email: omniauth['info']['email'] - ) - end + def github + split_name(omniauth['info']['name']).merge( + email: omniauth['info']['email'] + ) + end - def self.meetup_omniauth_attributes(omniauth) - self.split_name(omniauth['info']['name']) - end + def meetup + split_name(omniauth['info']['name']) + end + + def google_oauth2 + { + email: omniauth['info']['email'], + first_name: omniauth['info']['first_name'], + last_name: omniauth['info']['last_name'] + } + end - def self.google_oauth2_omniauth_attributes(omniauth) - { - email: omniauth['info']['email'], - first_name: omniauth['info']['first_name'], - last_name: omniauth['info']['last_name'] - } + private + + def split_name(full_name) + return {} if full_name.blank? + + components = full_name.split(' ') + { + first_name: components[0], + last_name: components[1..-1].join(' ') + } + end end end diff --git a/db/migrate/20140816220446_add_github_to_profile.rb b/db/migrate/20140816220446_add_github_to_profile.rb index 016a6a255..e7e10bcd2 100644 --- a/db/migrate/20140816220446_add_github_to_profile.rb +++ b/db/migrate/20140816220446_add_github_to_profile.rb @@ -1,5 +1,5 @@ class AddGithubToProfile < ActiveRecord::Migration def change - add_column :profiles, :github, :string + add_column :profiles, :github, :string end end diff --git a/db/migrate/20140831221929_fix_column_name.rb b/db/migrate/20140831221929_fix_column_name.rb index 78d763e55..8100d1fc5 100644 --- a/db/migrate/20140831221929_fix_column_name.rb +++ b/db/migrate/20140831221929_fix_column_name.rb @@ -1,5 +1,5 @@ class FixColumnName < ActiveRecord::Migration def change - rename_column :profiles, :github, :github_username + rename_column :profiles, :github, :github_username end end diff --git a/db/migrate/20151207004629_seed_chapters_from_regions.rb b/db/migrate/20151207004629_seed_chapters_from_regions.rb index d8f44f34b..666b9869f 100644 --- a/db/migrate/20151207004629_seed_chapters_from_regions.rb +++ b/db/migrate/20151207004629_seed_chapters_from_regions.rb @@ -49,7 +49,6 @@ def up chapter_name = "RailsBridge #{chapter_name}" unless chapter_name.match('RailsBridge') chapter = Chapter.find_or_create_by(name: chapter_name, organization: rb_org) external_event.update_attributes(chapter_id: chapter.id) - else end end diff --git a/db/seeds.rb b/db/seeds.rb index 9b4bca646..35a334386 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -3,8 +3,8 @@ end if Rails.env.development? - Seeder::seed_region - Seeder::seed_chapter - Seeder::admin_user - Seeder::seed_event + Seeder.seed_region + Seeder.seed_chapter + Seeder.admin_user + Seeder.seed_event end diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index c1ab510e2..fdfb2ea23 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -59,14 +59,14 @@ db_namespace = namespace :db do end desc "Restores the database from a dump file" - task :restore, [:filename] => [:environment, 'db:drop', 'db:create' ] do |t, args| + task :restore, [:filename] => [:environment, 'db:drop', 'db:create'] do |t, args| filename = Rails.root.join(args[:filename] || 'db/PRODUCTION.dump') cmd = nil with_config do |app, host, db| cmd = "pg_restore --verbose --host #{host} --clean --no-owner --no-acl --dbname #{db} #{filename}" end exec(cmd) - end + end private diff --git a/spec/controllers/events_controller_spec.rb b/spec/controllers/events_controller_spec.rb index d9f762ecc..7eef315b7 100644 --- a/spec/controllers/events_controller_spec.rb +++ b/spec/controllers/events_controller_spec.rb @@ -529,13 +529,13 @@ def make_request end it "includes the website title" do - expect(response.body).to include ('Bridge Troll Events') + expect(response.body).to include('Bridge Troll Events') end it "includes all events" do expect(Nokogiri::XML.parse(response.body).css(item_tag).length).to eq(2) - expect(response.body).to include ('DonutBridge') - expect(response.body).to include ('C5 Event!') + expect(response.body).to include('DonutBridge') + expect(response.body).to include('C5 Event!') end end @@ -560,13 +560,13 @@ def make_request end it "includes the website title" do - expect(response.body).to include ('Bridge Troll Events') + expect(response.body).to include('Bridge Troll Events') end it "includes all events" do expect(Nokogiri::XML.parse(response.body).css(item_tag).length).to eq(2) - expect(response.body).to include ('DonutBridge') - expect(response.body).to include ('C5 Event!') + expect(response.body).to include('DonutBridge') + expect(response.body).to include('C5 Event!') end end end diff --git a/spec/controllers/volunteers_controller_spec.rb b/spec/controllers/volunteers_controller_spec.rb index f1ffe1e41..4fb1aa3c0 100644 --- a/spec/controllers/volunteers_controller_spec.rb +++ b/spec/controllers/volunteers_controller_spec.rb @@ -27,7 +27,7 @@ render_views it "should be able to see list of volunteers" do - get :index , {event_id: @event.id} + get :index, {event_id: @event.id} expect(response).to be_success expect(response.body).to have_content 'Vol1' diff --git a/spec/features/event_email_request_spec.rb b/spec/features/event_email_request_spec.rb index af055e65e..9b1bf98f5 100644 --- a/spec/features/event_email_request_spec.rb +++ b/spec/features/event_email_request_spec.rb @@ -87,10 +87,10 @@ def choose_dropdown_option(dropdown_name, dropdown_option) end it "should show an accurate count of the # of cc'd recipients when selecting cc checkboxes" do - expect(page).to_not have_content ('1 event organizer') + expect(page).to_not have_content('1 event organizer') check 'CC Organizers' - expect(page).to have_content ('1 event organizer') + expect(page).to have_content('1 event organizer') end it 'lets the user review sent emails' do diff --git a/spec/features/event_rsvp_request_spec.rb b/spec/features/event_rsvp_request_spec.rb index a81b56cf9..f37ec5d04 100644 --- a/spec/features/event_rsvp_request_spec.rb +++ b/spec/features/event_rsvp_request_spec.rb @@ -202,7 +202,7 @@ context "for a non-teaching event" do before do - @event = create(:event, course_id:nil) + @event = create(:event, course_id: nil) @user = create(:user) sign_in_as @user visit volunteer_new_event_rsvp_path(@event) diff --git a/spec/features/locations_request_spec.rb b/spec/features/locations_request_spec.rb index 998693b7e..e9bdac6b9 100644 --- a/spec/features/locations_request_spec.rb +++ b/spec/features/locations_request_spec.rb @@ -1,34 +1,34 @@ require 'rails_helper' describe 'Locations' do - describe "should display a sortable list of locations" do #without user sign-in - before do - @my_location = create(:location) - end - - it "with a location name, address, city, state and zip" do - visit locations_path - - expect(page).to have_content(@my_location.name) - expect(page).to have_content(@my_location.address_1) - expect(page).to have_content(@my_location.city) - expect(page).to have_content(@my_location.state) - expect(page).to have_content(@my_location.zip) - end - - it "with the most recent event date" do - this_year = Date.current.year - expected_date = DateTime.new(this_year + 4, 1, 5, 12) - date_str = expected_date.strftime("%b %d, %Y") - @my_location.events << create(:event, starts_at: DateTime.new(this_year + 2, 1, 5)) - @my_location.events << create(:event, starts_at: expected_date) - - visit locations_path - - expect(page).to have_content(date_str) - end + describe "should display a sortable list of locations" do #without user sign-in + before do + @my_location = create(:location) end + it "with a location name, address, city, state and zip" do + visit locations_path + + expect(page).to have_content(@my_location.name) + expect(page).to have_content(@my_location.address_1) + expect(page).to have_content(@my_location.city) + expect(page).to have_content(@my_location.state) + expect(page).to have_content(@my_location.zip) + end + + it "with the most recent event date" do + this_year = Date.current.year + expected_date = DateTime.new(this_year + 4, 1, 5, 12) + date_str = expected_date.strftime("%b %d, %Y") + @my_location.events << create(:event, starts_at: DateTime.new(this_year + 2, 1, 5)) + @my_location.events << create(:event, starts_at: expected_date) + + visit locations_path + + expect(page).to have_content(date_str) + end + end + it "should create a new location" do @user = create(:user) region = create(:region, name: "Green Hill Zone") diff --git a/spec/features/new_event_request_spec.rb b/spec/features/new_event_request_spec.rb index bb386544e..dc9013511 100644 --- a/spec/features/new_event_request_spec.rb +++ b/spec/features/new_event_request_spec.rb @@ -72,9 +72,9 @@ visit "/events/new" expect(page).to have_select('event_location_id', options: [ - "Please select", - live_location.name_with_region - ]) + "Please select", + live_location.name_with_region + ]) end it 'allows organizers to specify a whitelist of allowed OSes', js: true do diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index 6e8b608cb..51f319ad6 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -40,9 +40,9 @@ def event_for_dates(starts_at, ends_at) end context "when called with an event occuring across two years" do - before(:each) do - @event = event_for_dates( DateTime.parse('2013-12-30'), - DateTime.parse('2014-01-02')) + before(:each) do + @event = event_for_dates(DateTime.parse('2013-12-30'), + DateTime.parse('2014-01-02')) end diff --git a/spec/jobs/reminder_sender_spec.rb b/spec/jobs/reminder_sender_spec.rb index f88f5a788..c474dbc34 100644 --- a/spec/jobs/reminder_sender_spec.rb +++ b/spec/jobs/reminder_sender_spec.rb @@ -38,7 +38,7 @@ event.event_sessions.first.update_attributes(starts_at: 4.days.from_now, ends_at: 5.days.from_now) @volunteer_session = create(:event_session, event: event, starts_at: 2.days.from_now, ends_at: 3.days.from_now, required_for_students: false, volunteers_only: true) - @volunteer_rsvp = build(:volunteer_rsvp, event: event).tap do |rsvp| + @volunteer_rsvp = build(:volunteer_rsvp, event: event).tap do |rsvp| rsvp.rsvp_sessions.build(event_session: @volunteer_session) rsvp.save! end diff --git a/spec/mailers/mailer_previews_spec.rb b/spec/mailers/mailer_previews_spec.rb index 95bb26c21..6ffd3c4b2 100644 --- a/spec/mailers/mailer_previews_spec.rb +++ b/spec/mailers/mailer_previews_spec.rb @@ -18,7 +18,7 @@ def find_leaves(klass) end before do - Seeder::seed_event(students_per_level_range: (1..1)) + Seeder.seed_event(students_per_level_range: (1..1)) end it 'has a preview for every devise mail' do diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb index bd59035b3..a948bde08 100644 --- a/spec/models/location_spec.rb +++ b/spec/models/location_spec.rb @@ -84,13 +84,13 @@ context "by someone who has organized an event at the given location" do it "should be archivable" do - expect(location.archivable_by?(organizer)).to be true + expect(location.archivable_by?(organizer)).to be true end end context "by a normal user" do it "should not be archivable" do - expect(location.archivable_by?(user)).to be false + expect(location.archivable_by?(user)).to be false end end end diff --git a/spec/seeds/seeds_spec.rb b/spec/seeds/seeds_spec.rb index 142e88ccc..514edcaed 100644 --- a/spec/seeds/seeds_spec.rb +++ b/spec/seeds/seeds_spec.rb @@ -22,16 +22,16 @@ def assert_no_rows_present describe "#seed_event" do it "creates an event which can cleanly destroy itself" do - Seeder::seed_event(students_per_level_range: (1..1)) + Seeder.seed_event(students_per_level_range: (1..1)) event = Event.last expect(event.title).to eq('Seeded Test Event') - Seeder::destroy_event(event) + Seeder.destroy_event(event) assert_no_rows_present end it "destroys itself when asked to create itself twice" do - Seeder::seed_event(students_per_level_range: (1..1)) - Seeder::seed_event(students_per_level_range: (1..1)) + Seeder.seed_event(students_per_level_range: (1..1)) + Seeder.seed_event(students_per_level_range: (1..1)) expect(Event.count).to eq(1) end @@ -40,10 +40,10 @@ def assert_no_rows_present innocent_user = create(:user) other_event.organizers << innocent_user - event = Seeder::seed_event(students_per_level_range: (1..1)) + event = Seeder.seed_event(students_per_level_range: (1..1)) event.organizers << innocent_user - Seeder::destroy_event(event) + Seeder.destroy_event(event) expect(User.find_by_id(innocent_user.id)).to be_present end end @@ -51,7 +51,7 @@ def assert_no_rows_present describe '#admin_user' do it 'creates an admin user' do expect { - Seeder::admin_user + Seeder.admin_user }.to change(User, :count).by(1) created_user = User.last expect(created_user).to be_admin