diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5486bd0c..5df301b9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,257 +1,31 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-11-27 22:40:12 +0530 using RuboCop version 0.51.0. +# on 2018-04-04 10:16:39 -0700 using RuboCop version 0.54.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 1 +# Offense count: 8 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: with_first_parameter, with_fixed_indentation -Layout/AlignParameters: - Exclude: - - 'Vagrantfile' - -# Offense count: 9 -# Cop supports --auto-correct. -Layout/ClosingParenthesisIndentation: - Exclude: - - 'app/controllers/conference_registrations_controller.rb' - - 'spec/support/omniauth_macros.rb' - -# Offense count: 14 -# Cop supports --auto-correct. -Layout/CommentIndentation: - Exclude: - - 'app/controllers/admin/comments_controller.rb' - - 'app/controllers/admin/difficulty_levels_controller.rb' - - 'app/models/conference.rb' - - 'app/models/program.rb' - - 'app/models/track.rb' - - 'spec/features/volunteers_spec.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/EmptyLineAfterMagicComment: - Exclude: - - 'spec/models/conference_spec.rb' - -# Offense count: 109 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundExceptionHandlingKeywords: - Exclude: - - 'app/models/payment.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'Guardfile' - - 'app/controllers/application_controller.rb' - - 'config.ru' - - 'db/migrate/20140623101032_create_ahoy_events.rb' - - 'db/migrate/20140701123203_add_events_per_week_to_conference.rb' - - 'db/migrate/20140719160903_create_delayed_jobs.rb' - - 'spec/models/conference_spec.rb' - -# Offense count: 42 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstParameterIndentation: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/IndentArray: - Exclude: - - 'app/models/conference.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: IndentationWidth. -Layout/IndentAssignment: - Exclude: - - 'app/helpers/format_helper.rb' - - 'app/models/conference.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/IndentHash: +# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/AlignHash: Exclude: - 'app/models/user.rb' - - 'db/migrate/20140701123203_add_events_per_week_to_conference.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: normal, rails -Layout/IndentationConsistency: - Exclude: - - 'app/controllers/users_controller.rb' - - 'app/models/event.rb' - - 'spec/controllers/subscriptions_controller_spec.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -Layout/LeadingCommentSpace: - Exclude: - - 'Guardfile' - - 'app/models/comment.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineArrayBraceLayout: - Exclude: - - 'app/controllers/conference_registrations_controller.rb' + - 'spec/mailers/mailbot_spec.rb' # Offense count: 5 # Cop supports --auto-correct. -Layout/MultilineBlockLayout: +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_parameter, with_fixed_indentation +Layout/AlignParameters: Exclude: - - 'app/serializers/conference_serializer.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineHashBraceLayout: - Exclude: - - 'app/serializers/conference_serializer.rb' - - 'spec/models/event_spec.rb' - -# Offense count: 40 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Enabled: false - -# Offense count: 53 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Enabled: false - -# Offense count: 23 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: aligned, indented -Layout/MultilineOperationIndentation: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/models/conference.rb' - - 'app/models/event.rb' - - 'db/migrate/20140701123203_add_events_per_week_to_conference.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/SpaceAfterComma: - Exclude: - - 'lib/tasks/data_demo.rake' - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: space, no_space -Layout/SpaceAroundEqualsInParameterDefault: - Exclude: - - 'app/helpers/format_helper.rb' - - 'app/models/event.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Layout/SpaceAroundOperators: - Exclude: - - 'lib/tasks/data.rake' - -# Offense count: 463 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, SupportedStylesForEmptyBraces. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceBeforeBlockBraces: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/SpaceBeforeComma: - Exclude: - - 'lib/tasks/data_demo.rake' - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/SpaceBeforeSemicolon: - Exclude: - - 'Guardfile' - -# Offense count: 54 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Exclude: - - 'app/controllers/admin/comments_controller.rb' - - 'app/controllers/admin/questions_controller.rb' - - 'app/helpers/application_helper.rb' - - 'app/models/program.rb' - - 'app/models/ticket.rb' - - 'app/models/user.rb' - - 'lib/tasks/events_registrations.rake' - - 'spec/controllers/admin/event_schedules_controller_spec.rb' - - 'spec/controllers/admin/schedules_controller_spec.rb' - - 'spec/features/splashpage_spec.rb' - - 'spec/models/ability_spec.rb' - - 'spec/models/user_spec.rb' - -# Offense count: 19 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Exclude: - - 'app/controllers/admin/conferences_controller.rb' - - 'app/controllers/api/v1/speakers_controller.rb' - - 'app/models/conference.rb' - - 'app/models/event_type.rb' - - 'app/models/user.rb' - - 'spec/models/event_spec.rb' - - 'spec/models/payment_spec.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Layout/SpaceInsidePercentLiteralDelimiters: - Exclude: - - 'Gemfile' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: final_newline, final_blank_line -Layout/TrailingBlankLines: - Exclude: - - 'lib/tasks/event_attatchments.rake' - - 'lib/tasks/roles.rake' + - 'spec/controllers/admin/conferences_controller_spec.rb' + - 'spec/controllers/admin/registration_periods_controller_spec.rb' + - 'spec/models/email_settings_spec.rb' # Offense count: 13 Lint/AmbiguousBlockAssociation: @@ -276,60 +50,34 @@ Lint/IneffectiveAccessModifier: - 'app/models/commercial.rb' - 'app/models/conference.rb' -# Offense count: 2 -Lint/RescueWithoutErrorClass: - Exclude: - - 'app/controllers/users/omniauth_callbacks_controller.rb' - - 'lib/tasks/migrate_config.rake' - -# Offense count: 2 -# Cop supports --auto-correct. -Lint/ScriptPermission: - Exclude: - - 'Guardfile' - - 'Rakefile' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. -Lint/UnusedBlockArgument: - Exclude: - - 'lib/tasks/user.rake' - -# Offense count: 136 +# Offense count: 140 Metrics/AbcSize: - Max: 98 + Max: 94 -# Offense count: 258 +# Offense count: 310 # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: - Max: 471 + Max: 1420 -# Offense count: 28 +# Offense count: 32 Metrics/CyclomaticComplexity: Max: 14 -# Offense count: 2774 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Metrics/LineLength: - Max: 619 - -# Offense count: 133 +# Offense count: 136 # Configuration parameters: CountComments. Metrics/MethodLength: - Max: 63 + Max: 60 -# Offense count: 4 +# Offense count: 5 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 200 + Max: 180 -# Offense count: 20 +# Offense count: 22 Metrics/PerceivedComplexity: Max: 16 -# Offense count: 20 +# Offense count: 18 Naming/AccessorMethodName: Exclude: - 'app/controllers/application_controller.rb' @@ -367,44 +115,268 @@ Naming/PredicateName: - 'app/models/contact.rb' # Offense count: 2 -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: io, id, to +Naming/UncommunicativeMethodParamName: + Exclude: + - 'app/models/conference.rb' + +# Offense count: 2 +# Configuration parameters: EnforcedStyle. # SupportedStyles: snake_case, normalcase, non_integer Naming/VariableNumber: Exclude: - 'spec/models/ticket_purchase_spec.rb' - # Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: is_a?, kind_of? -Style/ClassCheck: +# Configuration parameters: EnforcedStyle, Include. +# SupportedStyles: action, filter +# Include: app/controllers/**/*.rb +Rails/ActionFilter: Exclude: + - 'app/controllers/users/omniauth_callbacks_controller.rb' + +# Offense count: 103 +# Cop supports --auto-correct. +Rails/ActiveRecordAliases: + Enabled: false + +# Offense count: 124 +# Cop supports --auto-correct. +Rails/ApplicationRecord: + Enabled: false + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent. +Rails/Blank: + Exclude: + - 'app/controllers/conferences_controller.rb' + - 'app/controllers/users/omniauth_callbacks_controller.rb' + - 'app/models/program.rb' + - 'app/models/user.rb' + - 'db/migrate/20160309182655_remove_dietary_choices_table.rb' + - 'spec/factories/event_schedule.rb' + +# Offense count: 19 +# Configuration parameters: Include. +# Include: db/migrate/*.rb +Rails/CreateTableWithTimestamps: + Enabled: false + +# Offense count: 126 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, flexible +Rails/Date: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforceForPrefixed. +Rails/Delegate: + Exclude: + - 'app/models/event.rb' + - 'app/models/room.rb' + - 'app/models/track.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: Whitelist. +# Whitelist: find_by_sql +Rails/DynamicFindBy: + Exclude: + - 'app/controllers/admin/events_controller.rb' + - 'db/migrate/20140701123203_add_events_per_week_to_conference.rb' + +# Offense count: 5 +Rails/FilePath: + Exclude: + - 'app/pdfs/ticket_pdf.rb' + - 'spec/features/lodgings_spec.rb' + - 'spec/features/sponsor_spec.rb' + - 'spec/spec_helper.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/FindBy: + Exclude: + - 'app/models/event.rb' + - 'app/models/openid.rb' + - 'app/models/ticket_purchase.rb' + - 'app/models/user.rb' + +# Offense count: 6 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/HasAndBelongsToMany: + Exclude: + - 'app/models/conference.rb' + - 'app/models/qanswer.rb' + - 'app/models/question.rb' + - 'app/models/registration.rb' + - 'app/models/vchoice.rb' + +# Offense count: 18 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/HasManyOrHasOneDependent: + Exclude: + - 'app/models/answer.rb' + - 'app/models/event.rb' + - 'app/models/payment.rb' + - 'app/models/physical_ticket.rb' + - 'app/models/question_type.rb' + - 'app/models/registration.rb' + - 'app/models/role.rb' + - 'app/models/room.rb' + - 'app/models/sponsorship_level.rb' + - 'app/models/ticket_purchase.rb' + - 'app/models/track.rb' + - 'app/models/user.rb' + - 'app/models/vday.rb' + - 'app/models/visit.rb' + - 'app/models/vposition.rb' + +# Offense count: 254 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: spec/**/*, test/**/* +Rails/HttpPositionalArguments: + Enabled: false + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: numeric, symbolic +Rails/HttpStatus: + Exclude: + - 'app/controllers/admin/commercials_controller.rb' + - 'app/controllers/admin/event_schedules_controller.rb' + - 'app/controllers/admin/programs_controller.rb' + - 'app/controllers/admin/tracks_controller.rb' + - 'app/controllers/admin/venue_commercials_controller.rb' + - 'app/controllers/commercials_controller.rb' + +# Offense count: 14 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/InverseOf: + Exclude: + - 'app/models/booth.rb' + - 'app/models/conference.rb' + - 'app/models/event.rb' + - 'app/models/program.rb' + - 'app/models/track.rb' + - 'app/models/user.rb' + - 'app/models/venue.rb' + - 'app/models/visit.rb' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/controllers/**/*.rb +Rails/LexicallyScopedActionFilter: + Exclude: + - 'app/controllers/registrations_controller.rb' + +# Offense count: 4 +Rails/OutputSafety: + Exclude: + - 'app/helpers/events_helper.rb' + - 'app/helpers/format_helper.rb' + - 'app/models/commercial.rb' + +# Offense count: 15 +# Cop supports --auto-correct. +Rails/PluralizationGrammar: + Exclude: + - 'spec/models/conference_spec.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Rails/Presence: + Exclude: + - 'app/controllers/schedules_controller.rb' + - 'app/helpers/application_helper.rb' + - 'app/models/user.rb' + - 'db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb' + +# Offense count: 23 +# Cop supports --auto-correct. +# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. +Rails/Present: + Exclude: + - 'app/helpers/users_helper.rb' + - 'app/models/campaign.rb' + - 'app/models/cfp.rb' - 'app/models/email_settings.rb' + - 'app/models/event.rb' + - 'app/models/program.rb' + - 'app/models/venue.rb' + - 'db/migrate/20141104131625_generate_username.rb' + +# Offense count: 52 +# Configuration parameters: Include. +# Include: db/migrate/*.rb +Rails/ReversibleMigration: + Exclude: + - 'db/migrate/20140530082708_remove_color_defaults.rb' + - 'db/migrate/20140605125153_update_event_states.rb' + - 'db/migrate/20140610173021_change_person_id_to_user_id_in_registrations.rb' + - 'db/migrate/20140611123926_change_person_id_to_user_id_in_votes.rb' + - 'db/migrate/20140623150541_drop_person_and_event_person_tables.rb' + - 'db/migrate/20140731165107_move_conference_contact_details_to_contact.rb' + - 'db/migrate/20140801164901_move_conference_media_to_commercial.rb' + - 'db/migrate/20140801170430_move_event_media_to_commercial.rb' + - 'db/migrate/20140820093735_migrating_supporter_registrations_to_ticket_users.rb' + - 'db/migrate/20140821103643_split_ticket_price_in_price_and_currency.rb' + - 'db/migrate/20140825093132_move_splashpage_attributes_from_conference_to_splashpage.rb' + - 'db/migrate/20140930092923_move_sponsor_email_to_contact.rb' + - 'db/migrate/20141117222919_drop_splash_descriptions_and_photo.rb' + - 'db/migrate/20141130182139_drop_table_event_attachments.rb' + +# Offense count: 8 +# Configuration parameters: Blacklist. +# Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters +Rails/SkipsModelValidations: + Exclude: + - 'app/models/concerns/revision_count.rb' + - 'db/migrate/20140730104658_migrate_roles_for_cancancan.rb' + - 'db/migrate/20161229080315_add_comments_count_to_events.rb' + - 'db/migrate/20180226032958_add_created_at_and_updated_at_to_event_types.rb' + - 'db/migrate/20180313012253_add_timestamps_to_tickets.rb' + - 'lib/tasks/user.rake' + - 'spec/controllers/conferences_controller_spec.rb' + +# Offense count: 50 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, flexible +Rails/TimeZone: + Exclude: + - 'app/models/comment.rb' + - 'app/models/conference.rb' + - 'db/migrate/20180226032958_add_created_at_and_updated_at_to_event_types.rb' + - 'db/migrate/20180313012253_add_timestamps_to_tickets.rb' + - 'lib/tasks/dump_db.rake' + - 'spec/controllers/admin/comments_controller_spec.rb' + - 'spec/controllers/admin/programs_controller_spec.rb' + - 'spec/factories/users.rb' + - 'spec/models/campaign_spec.rb' + - 'spec/models/conference_spec.rb' + +# Offense count: 2 +Security/Open: + Exclude: + - 'app/pdfs/ticket_pdf.rb' # Offense count: 1 Style/ClassVars: Exclude: - 'spec/support/kneet_connections.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Style/ColonMethodCall: - Exclude: - - 'app/models/commercial.rb' - - 'app/models/contact.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions. -# SupportedStyles: assign_to_condition, assign_inside_condition -Style/ConditionalAssignment: - Exclude: - - 'app/helpers/format_helper.rb' - - 'db/migrate/20140610165551_migrate_data_person_to_user.rb' - - 'db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb' - -# Offense count: 9 +# Offense count: 11 Style/DateTime: Exclude: - 'app/models/conference.rb' @@ -412,301 +384,66 @@ Style/DateTime: - 'spec/models/conference_spec.rb' - 'spec/models/program_spec.rb' -# Offense count: 488 +# Offense count: 495 Style/Documentation: Enabled: false -# Offense count: 2 -# Cop supports --auto-correct. -Style/EmptyCaseCondition: - Exclude: - - 'app/helpers/format_helper.rb' - - 'app/helpers/versions_helper.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Style/EmptyLiteral: - Exclude: - - 'spec/models/conference_spec.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: compact, expanded -Style/EmptyMethod: - Exclude: - - 'app/controllers/admin/lodgings_controller.rb' - - 'app/controllers/admin/registration_periods_controller.rb' - - 'app/controllers/users_controller.rb' - - 'db/migrate/20121223115125_create_tracks_table.rb' - - 'db/migrate/20121223115135_create_events_table.rb' - - 'db/migrate/20130103134212_create_registrations_table.rb' - - 'db/migrate/20130206192339_rename_attending_social_events_with_partner.rb' - - 'db/migrate/20130216122155_set_registration_defaults_to_false.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Style/Encoding: - Exclude: - - 'app/uploaders/picture_uploader.rb' - - 'spec/models/conference_spec.rb' - -# Offense count: 32 +# Offense count: 20 # Configuration parameters: MinBodyLength. Style/GuardClause: - Enabled: false - -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -Style/HashSyntax: Exclude: - - 'Gemfile' - - 'lib/tasks/user.rake' - -# Offense count: 22 -# Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. -Style/IfUnlessModifier: - Exclude: - - 'app/controllers/api/v1/events_controller.rb' + - 'app/controllers/admin/organizations_controller.rb' - 'app/controllers/conference_registrations_controller.rb' - - 'app/controllers/users/omniauth_callbacks_controller.rb' - - 'app/helpers/application_helper.rb' - - 'app/models/commercial.rb' - - 'app/models/conference.rb' - - 'app/models/email_settings.rb' - - 'app/models/user.rb' - - 'db/migrate/20151031092713_change_conference_id_to_venue_id_in_rooms.rb' - - 'lib/tasks/events_registrations.rake' - - 'spec/controllers/admin/conferences_controller_spec.rb' - - 'spec/support/flash.rb' - -# Offense count: 8 -# Cop supports --auto-correct. -Style/LineEndConcatenation: - Exclude: - - 'spec/features/cfp_spec.rb' - - 'spec/features/conference_spec.rb' - - 'spec/features/registration_periods_spec.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline -Style/MethodDefParentheses: - Exclude: - - 'app/models/conference.rb' - - 'app/models/user.rb' - - 'lib/tasks/demo_data_for_development.rake' - -# Offense count: 7 -# Cop supports --auto-correct. -Style/MultilineIfModifier: - Exclude: - 'app/controllers/conferences_controller.rb' + - 'app/controllers/registrations_controller.rb' - 'app/controllers/schedules_controller.rb' + - 'app/helpers/events_helper.rb' + - 'app/models/ability.rb' - 'app/models/cfp.rb' - - 'app/models/event.rb' + - 'app/models/conference.rb' + - 'app/models/registration.rb' - 'app/models/registration_period.rb' + - 'app/models/user.rb' + - 'db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb' + - 'lib/tasks/data.rake' -# Offense count: 2 +# Offense count: 37 # Cop supports --auto-correct. -Style/MutableConstant: - Exclude: - - 'app/models/event_user.rb' - - 'lib/tasks/migrate_config.rake' - -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: Whitelist. -# Whitelist: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with -Style/NestedParenthesizedCalls: - Exclude: - - 'spec/features/conference_spec.rb' - - 'spec/models/conference_spec.rb' - -# Offense count: 27 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. -# SupportedStyles: skip_modifier_ifs, always -Style/Next: +Style/IfUnlessModifier: Enabled: false -# Offense count: 117 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedOctalStyle, SupportedOctalStyles. -# SupportedOctalStyles: zero_with_o, zero_only -Style/NumericLiteralPrefix: +# Offense count: 1 +Style/MixinUsage: Exclude: - - 'spec/controllers/admin/conferences_controller_spec.rb' - - 'spec/controllers/conference_registration_controller_spec.rb' - - 'spec/helpers/date_time_helper_spec.rb' - - 'spec/models/conference_spec.rb' - - 'spec/models/email_settings_spec.rb' - - 'spec/models/registration_spec.rb' - - 'spec/serializers/conference_serializer_spec.rb' - - 'spec/serializers/event_serializer_spec.rb' + - 'spec/spec_helper.rb' -# Offense count: 7 +# Offense count: 41 # Cop supports --auto-correct. -# Configuration parameters: Strict. -Style/NumericLiterals: - MinDigits: 15 - -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles. +# Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - 'spec/**/*' - 'app/controllers/admin/conferences_controller.rb' + - 'app/helpers/application_helper.rb' - 'app/helpers/date_time_helper.rb' - 'app/helpers/format_helper.rb' + - 'app/models/cfp.rb' + - 'app/models/conference.rb' + - 'app/models/event.rb' + - 'app/models/program.rb' + - 'app/models/registration.rb' + - 'app/models/ticket_purchase.rb' - 'app/models/user.rb' + - 'lib/tasks/events_registrations.rake' # Offense count: 3 Style/OptionalArguments: Exclude: - 'app/models/event.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Style/OrAssignment: - Exclude: - - 'app/controllers/schedules_controller.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: AllowSafeAssignment. -Style/ParenthesesAroundCondition: - Exclude: - - 'app/controllers/admin/base_controller.rb' - - 'app/controllers/application_controller.rb' - - 'app/helpers/format_helper.rb' - -# Offense count: 15 -# Cop supports --auto-correct. -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Exclude: - - 'Gemfile' - - 'app/controllers/admin/users_controller.rb' - - 'app/models/cfp.rb' - - 'app/models/comment.rb' - - 'app/models/commercial.rb' - - 'app/models/conference.rb' - - 'app/models/contact.rb' - - 'app/models/registration.rb' - - 'app/models/subscription.rb' - - 'app/models/track.rb' - - 'app/uploaders/picture_uploader.rb' - - 'spec/models/program_spec.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: short, verbose -Style/PreferredHashMethods: - Exclude: - - 'lib/tasks/migrate_config.rake' - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles. -# SupportedStyles: compact, exploded -Style/RaiseArgs: - EnforcedStyle: compact - -# Offense count: 1 -# Cop supports --auto-correct. -Style/RedundantParentheses: - Exclude: - - 'app/controllers/admin/base_controller.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. -# SupportedStyles: slashes, percent_r, mixed -Style/RegexpLiteral: - Exclude: - - 'Guardfile' - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: only_raise, only_fail, semantic -Style/SignalException: - Exclude: - - 'lib/tasks/user.rake' - - 'spec/support/flash.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AllowIfMethodIsEmpty. -Style/SingleLineMethods: - Exclude: - - 'Guardfile' - -# Offense count: 16 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiterals: - Exclude: - - 'Gemfile' - - 'Vagrantfile' - - 'lib/tasks/dump_db.rake' - - 'lib/tasks/events_registrations.rake' - - 'lib/tasks/factory_girl.rake' - - 'lib/tasks/user.rake' - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiteralsInInterpolation: - Exclude: - - 'lib/tasks/dump_db.rake' - -# Offense count: 79 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, MinSize, SupportedStyles. -# SupportedStyles: percent, brackets -Style/SymbolArray: - Enabled: false - -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. -# IgnoredMethods: respond_to, define_method -Style/SymbolProc: - Exclude: - - 'app/controllers/admin/comments_controller.rb' - - 'app/controllers/admin/questions_controller.rb' - - 'app/helpers/application_helper.rb' - - 'app/models/ability.rb' - - 'app/models/admin_ability.rb' - - 'db/migrate/20140730104658_migrate_roles_for_cancancan.rb' - - 'spec/controllers/admin/conferences_controller_spec.rb' - - 'spec/support/flash.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment. -# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex -Style/TernaryParentheses: - Exclude: - - 'app/helpers/format_helper.rb' - -# Offense count: 23 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInLiteral: - Exclude: - - 'Guardfile' - - 'db/migrate/20140701123203_add_events_per_week_to_conference.rb' - - 'spec/models/conference_spec.rb' +# Offense count: 2835 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 619 diff --git a/Gemfile b/Gemfile index 69610b57..9399694a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,9 @@ +# frozen_string_literal: true + source 'https://rubygems.org' # rails-assets requires >= 1.8.4 -if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.8.4') - abort "Bundler version >= 1.8.4 is required" -end +abort 'Bundler version >= 1.8.4 is required' if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.8.4') # as web framework gem 'rails', '~> 5.0.5' @@ -60,7 +60,7 @@ gem 'rolify' gem 'unobtrusive_flash', '>=3' # as state machine -gem 'transitions', :require => %w( transitions active_record/transitions ) +gem 'transitions', require: %w[transitions active_record/transitions] # for comments gem 'acts_as_commentable_with_threading' @@ -164,7 +164,7 @@ gem 'piwik_analytics', '~> 1.0.1' # for recurring jobs gem 'delayed_job_active_record' -gem 'whenever', :require => false +gem 'whenever', require: false # to run scripts gem 'daemons' @@ -192,7 +192,7 @@ gem 'dotenv-rails' gem 'feature' # For countable.js -gem "countable-rails", "~> 0.0.1" +gem 'countable-rails', '~> 0.0.1' # Both are not in a group as we use it also for rake data:demo # for fake data @@ -244,7 +244,7 @@ group :test do # as test framework gem 'capybara' gem 'database_cleaner' - gem 'phantomjs', :require => 'phantomjs/poltergeist' + gem 'phantomjs', require: 'phantomjs/poltergeist' gem 'poltergeist' gem 'rspec-rails', '~> 3.5', '>= 3.5.2' # for measuring test coverage diff --git a/Guardfile b/Guardfile old mode 100644 new mode 100755 index 3f92b1a3..29f435ff --- a/Guardfile +++ b/Guardfile @@ -1,4 +1,6 @@ #!/usr/bin/ruby +# frozen_string_literal: true + # # More info at https://github.com/guard/guard#readme @@ -8,7 +10,9 @@ guard_opts = { cmd: 'spring rspec' } -def model_specs ; 'spec/models' end +def model_specs + 'spec/models' +end def model_spec(model) "spec/models/#{model}_spec.rb" @@ -19,19 +23,19 @@ def all_testunit_tests model_tests, controller_tests, helper_tests, - integration_tests, + integration_tests ] end def all_specs [ - model_specs, + model_specs ] end def startup_guards - watch(%r{^Gemfile$}) { yield } - watch(%r{^Gemfile.lock$}) { yield } + watch(/^Gemfile$/) { yield } + watch(/^Gemfile.lock$/) { yield } watch(%r{^config/routes.rb$}) { yield } watch(%r{^config/application\.rb$}) { yield } watch(%r{^config/environment\.rb$}) { yield } @@ -44,14 +48,14 @@ end def rspec_guards watch(%r{^spec/factories/.+\.rb$}) { all_specs } watch(%r{^spec/.+_spec\.rb$}) - watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } end group :rspec do guard 'rspec', guard_opts do - #startup_guards { all_specs } + # startup_guards { all_specs } rspec_guards - #all_specs + # all_specs end end diff --git a/Rakefile b/Rakefile old mode 100644 new mode 100755 index f29eb6f1..407636a7 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,9 @@ #!/usr/bin/env rake +# frozen_string_literal: true + # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require File.expand_path('config/application', __dir__) Osem::Application.load_tasks diff --git a/Vagrantfile b/Vagrantfile index bf3622e4..8e3c3868 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # -*- mode: ruby -*- # vi: set ft=ruby : @@ -12,7 +14,7 @@ Vagrant.configure(2) do |config| # Every Vagrant development environment requires a box. You can search for # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "opensuse/openSUSE-42.2-x86_64" + config.vm.box = 'opensuse/openSUSE-42.2-x86_64' # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs @@ -22,7 +24,7 @@ Vagrant.configure(2) do |config| # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. - config.vm.network "forwarded_port", guest: 3000, host: 3000 + config.vm.network 'forwarded_port', guest: 3000, host: 3000 # Create a private network, which allows host-only access to the machine # using a specific IP. @@ -47,8 +49,8 @@ Vagrant.configure(2) do |config| # mount without working about the group mismatch VAGRANT_UID = 1000 # User vagrant VAGRANT_GID = 100 # Group users - config.vm.synced_folder ".", "/vagrant", - owner: VAGRANT_UID, group: VAGRANT_GID + config.vm.synced_folder '.', '/vagrant', + owner: VAGRANT_UID, group: VAGRANT_GID # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. These expose provider-specific options. @@ -75,7 +77,7 @@ Vagrant.configure(2) do |config| # Enable provisioning with a shell script. Additional provisioners such as # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the # documentation for more information about their specific syntax and use. - config.vm.provision :shell, path: "bootstrap.sh" + config.vm.provision :shell, path: 'bootstrap.sh' # config.vm.provision "shell", inline: <<-SHELL # sudo apt-get update # sudo apt-get install -y apache2 diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index 8c2db1f4..e2c31014 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class BaseController < ApplicationController before_action :verify_user_admin @@ -9,7 +11,7 @@ module Admin end def verify_user_admin - if (current_user.nil?) + if current_user.nil? redirect_to sign_in_path return false end @@ -17,7 +19,7 @@ module Admin (current_user.has_cached_role? :info_desk, :any) || (current_user.has_cached_role? :organization_admin, :any) || (current_user.has_cached_role? :volunteers_coordinator, :any) || (current_user.has_cached_role? :track_organizer, :any) || current_user.is_admin - raise CanCan::AccessDenied.new('You are not authorized to access this page.') + raise CanCan::AccessDenied, 'You are not authorized to access this page.' end end end diff --git a/app/controllers/admin/booths_controller.rb b/app/controllers/admin/booths_controller.rb index e41d11d3..ebe5869e 100644 --- a/app/controllers/admin/booths_controller.rb +++ b/app/controllers/admin/booths_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class BoothsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -51,7 +53,7 @@ module Admin def update @url = admin_conference_booth_path(@conference.short_title, @booth.id) - @booth.update_attributes(booth_params) + @booth.update(booth_params) if @booth.save redirect_to admin_conference_booths_path, @@ -67,9 +69,7 @@ module Admin @booth.accept! if @booth.save - if @conference.email_settings.send_on_booths_acceptance - Mailbot.conference_booths_acceptance_mail(@booth).deliver - end + Mailbot.conference_booths_acceptance_mail(@booth).deliver if @conference.email_settings.send_on_booths_acceptance redirect_to admin_conference_booths_path(conference_id: @conference.short_title), notice: 'Booth successfully accepted!' else diff --git a/app/controllers/admin/campaigns_controller.rb b/app/controllers/admin/campaigns_controller.rb index 142e07ac..271b253f 100644 --- a/app/controllers/admin/campaigns_controller.rb +++ b/app/controllers/admin/campaigns_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class CampaignsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -25,7 +27,7 @@ module Admin def edit; end def update - if @campaign.update_attributes(campaign_params) + if @campaign.update(campaign_params) redirect_to admin_conference_campaigns_path(conference_id: @conference.short_title), notice: "Campaign '#{@campaign.name}' successfully updated." else diff --git a/app/controllers/admin/cfps_controller.rb b/app/controllers/admin/cfps_controller.rb index 18b493eb..5102951a 100644 --- a/app/controllers/admin/cfps_controller.rb +++ b/app/controllers/admin/cfps_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class CfpsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -33,7 +35,7 @@ module Admin send_mail_on_cfp_dates_updates = @cfp.notify_on_cfp_date_update? - if @cfp.update_attributes(cfp_params) + if @cfp.update(cfp_params) ConferenceCfpUpdateMailJob.perform_later(@conference) if send_mail_on_cfp_dates_updates redirect_to admin_conference_program_cfps_path(@conference.short_title), notice: 'Call for papers successfully updated.' diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index cb57464d..5dfbe232 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class CommentsController < Admin::BaseController load_and_authorize_resource @@ -20,9 +22,9 @@ module Admin Comment.accessible_by(current_ability).joins('INNER JOIN events ON commentable_id = events.id').order('events.title', 'comments.created_at DESC') end -# Grouping all comments by conference, and by event. It returns {:conference => {:event => [{comment_2}, {comment_1 }]}} + # Grouping all comments by conference, and by event. It returns {:conference => {:event => [{comment_2}, {comment_1 }]}} def grouped_comments(remarks) - remarks.group_by{ |comment| comment.commentable.program.conference }.map {|conference, comments| [conference, comments.group_by{|comment| comment.commentable}]}.to_h + remarks.group_by { |comment| comment.commentable.program.conference }.map { |conference, comments| [conference, comments.group_by(&:commentable)] }.to_h end end end diff --git a/app/controllers/admin/commercials_controller.rb b/app/controllers/admin/commercials_controller.rb index 1bc587ce..11c3ea58 100644 --- a/app/controllers/admin/commercials_controller.rb +++ b/app/controllers/admin/commercials_controller.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + module Admin class CommercialsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource through: :conference, except: [:new, :create] + load_and_authorize_resource through: :conference, except: %i[new create] def index @commercials = @conference.commercials @@ -43,7 +45,7 @@ module Admin def render_commercial result = Commercial.render_from_url(params[:url]) if result[:error] - render text: result[:error], status: 400 + render text: result[:error], status: :bad_request else render text: result[:html] end diff --git a/app/controllers/admin/conferences_controller.rb b/app/controllers/admin/conferences_controller.rb index 1fc978af..9005de0c 100644 --- a/app/controllers/admin/conferences_controller.rb +++ b/app/controllers/admin/conferences_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class ConferencesController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -22,11 +24,11 @@ module Admin @total_withdrawn = Event.where(state: :withdrawn).count @new_withdrawn = Event - .where('state = ? and created_at > ?', 'withdrawn', current_user.last_sign_in_at).count + .where('state = ? and created_at > ?', 'withdrawn', 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 + .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) @@ -99,7 +101,7 @@ module Admin @conference.assign_attributes(conference_params) send_mail_on_conf_update = @conference.notify_on_dates_changed? - if @conference.update_attributes(conference_params) + if @conference.update(conference_params) ConferenceDateUpdateMailJob.perform_later(@conference) if send_mail_on_conf_update redirect_to edit_admin_conference_path(id: @conference.short_title), notice: 'Conference was successfully updated.' @@ -121,7 +123,7 @@ module Admin @total_submissions = @all_events.count @new_submissions = @all_events - .where('created_at > ?', current_user.last_sign_in_at).count + .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) @@ -136,7 +138,7 @@ module Admin @conference_progress = @conference.get_status # Line charts - @registrations = {@conference.short_title => @conference.get_registrations_per_week} + @registrations = { @conference.short_title => @conference.get_registrations_per_week } @registration_weeks = [0] @registration_weeks.push(@registrations[@conference.short_title].length) @@ -173,9 +175,9 @@ module Admin @difficulty_levels_distribution = @conference.difficulty_levels_distribution @difficulty_levels_distribution_confirmed = @conference - .difficulty_levels_distribution(:confirmed) + .difficulty_levels_distribution(:confirmed) @difficulty_levels_distribution_withdrawn = @conference - .difficulty_levels_distribution(:withdrawn) + .difficulty_levels_distribution(:withdrawn) @tracks_distribution = @conference.tracks_distribution @tracks_distribution_confirmed = @conference.tracks_distribution(:confirmed) diff --git a/app/controllers/admin/contacts_controller.rb b/app/controllers/admin/contacts_controller.rb index 1003e098..a0364251 100644 --- a/app/controllers/admin/contacts_controller.rb +++ b/app/controllers/admin/contacts_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class ContactsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title diff --git a/app/controllers/admin/difficulty_levels_controller.rb b/app/controllers/admin/difficulty_levels_controller.rb index 7e02412c..0669c8cc 100644 --- a/app/controllers/admin/difficulty_levels_controller.rb +++ b/app/controllers/admin/difficulty_levels_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class DifficultyLevelsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -5,7 +7,7 @@ module Admin load_and_authorize_resource through: :program def index -# authorize! :index, DifficultyLevel.new(program_id: @program.id) + # authorize! :index, DifficultyLevel.new(program_id: @program.id) end def edit; end @@ -26,7 +28,7 @@ module Admin end def update - if @difficulty_level.update_attributes(difficulty_level_params) + if @difficulty_level.update(difficulty_level_params) redirect_to admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title), notice: 'Difficulty level successfully updated.' else diff --git a/app/controllers/admin/emails_controller.rb b/app/controllers/admin/emails_controller.rb index a4d6fe04..bb14b35d 100644 --- a/app/controllers/admin/emails_controller.rb +++ b/app/controllers/admin/emails_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class EmailsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -6,11 +8,13 @@ module Admin def update if @conference.email_settings.update(email_params) redirect_to admin_conference_emails_path( - @conference.short_title), + @conference.short_title + ), notice: 'Email settings have been successfully updated.' else redirect_to admin_conference_emails_path( - @conference.short_title), + @conference.short_title + ), error: "Updating email settings failed. #{@conference.email_settings.errors.to_a.join('. ')}." end end diff --git a/app/controllers/admin/event_schedules_controller.rb b/app/controllers/admin/event_schedules_controller.rb index 04713093..8af18289 100644 --- a/app/controllers/admin/event_schedules_controller.rb +++ b/app/controllers/admin/event_schedules_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class EventSchedulesController < Admin::BaseController load_and_authorize_resource :event_schedule @@ -6,7 +8,7 @@ module Admin if @event_schedule.save render json: { event_schedule_id: @event_schedule.id } else - render json: { errors: "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: 422 + render json: { errors: "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: :unprocessable_entity end end @@ -14,7 +16,7 @@ module Admin if @event_schedule.update(event_schedule_params) render json: { event_schedule_id: @event_schedule.id } else - render json: { errors: "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: 422 + render json: { errors: "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: :unprocessable_entity end end @@ -22,7 +24,7 @@ module Admin if @event_schedule.destroy render json: {} else - render json: { errors: "The event couldn't be unscheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: 422 + render json: { errors: "The event couldn't be unscheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: :unprocessable_entity end end diff --git a/app/controllers/admin/event_types_controller.rb b/app/controllers/admin/event_types_controller.rb index 4576ad5d..a171b427 100644 --- a/app/controllers/admin/event_types_controller.rb +++ b/app/controllers/admin/event_types_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class EventTypesController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -24,7 +26,7 @@ module Admin end def update - if @event_type.update_attributes(event_type_params) + if @event_type.update(event_type_params) redirect_to admin_conference_program_event_types_path(conference_id: @conference.short_title), notice: 'Event type successfully updated.' else diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index 2e9886bf..a79af61c 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class EventsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -7,7 +9,7 @@ module Admin # For some reason this doesn't work, so a workaround is used # load_and_authorize_resource :track, through: :program, only: [:index, :show, :edit] - before_action :assign_tracks, only: [:index, :show, :edit] + before_action :assign_tracks, only: %i[index show edit] def index @difficulty_levels = @program.difficulty_levels @@ -17,7 +19,7 @@ module Admin @scheduled_event_distribution = @conference.scheduled_event_distribution @file_name = "events_for_#{@conference.short_title}" @event_export_option = params[:event_export_option] - @export_formats = [:pdf, :csv, :xlsx] + @export_formats = %i[pdf csv xlsx] respond_to do |format| format.html @@ -69,7 +71,7 @@ module Admin def update @languages = @program.languages_list - if @event.update_attributes(event_params) + if @event.update(event_params) if request.xhr? render js: 'index' @@ -139,8 +141,8 @@ module Admin def vote @votes = @event.votes.includes(:user) - if (votes = current_user.votes.find_by_event_id(params[:id])) - votes.update_attributes(rating: params[:rating]) + if (votes = current_user.votes.find_by(event_id: params[:id])) + votes.update(rating: params[:rating]) else @myvote = @event.votes.build @myvote.user = current_user @@ -172,13 +174,14 @@ module Admin def event_params params.require(:event).permit( - # Set also in proposals controller - :title, :subtitle, :event_type_id, :abstract, :description, :require_registration, :difficulty_level_id, - # Set only in admin/events controller - :track_id, :state, :language, :is_highlight, :max_attendees, - # Not used anymore? - :proposal_additional_speakers, :user, :users_attributes, - speaker_ids: []) + # Set also in proposals controller + :title, :subtitle, :event_type_id, :abstract, :description, :require_registration, :difficulty_level_id, + # Set only in admin/events controller + :track_id, :state, :language, :is_highlight, :max_attendees, + # Not used anymore? + :proposal_additional_speakers, :user, :users_attributes, + speaker_ids: [] + ) end def comment_params diff --git a/app/controllers/admin/lodgings_controller.rb b/app/controllers/admin/lodgings_controller.rb index 85c5ff26..69fa2df5 100644 --- a/app/controllers/admin/lodgings_controller.rb +++ b/app/controllers/admin/lodgings_controller.rb @@ -1,10 +1,11 @@ +# frozen_string_literal: true + module Admin class LodgingsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title load_and_authorize_resource :lodging, through: :conference - def index - end + def index; end def new @lodging = @conference.lodgings.new @@ -24,7 +25,7 @@ module Admin def edit; end def update - if @lodging.update_attributes(lodging_params) + if @lodging.update(lodging_params) redirect_to admin_conference_lodgings_path(conference_id: @conference.short_title), notice: 'Lodging successfully updated.' else diff --git a/app/controllers/admin/organizations_controller.rb b/app/controllers/admin/organizations_controller.rb index 8562d61a..c3e6910b 100644 --- a/app/controllers/admin/organizations_controller.rb +++ b/app/controllers/admin/organizations_controller.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + module Admin class OrganizationsController < Admin::BaseController load_and_authorize_resource :organization - before_action :verify_user, only: [:assign_org_admins, :unassign_org_admins] + before_action :verify_user, only: %i[assign_org_admins unassign_org_admins] def index @organizations = Organization.all @@ -25,7 +27,7 @@ module Admin def edit; end def update - if @organization.update_attributes(organization_params) + if @organization.update(organization_params) redirect_to admin_organizations_path, notice: 'Organization successfully updated' else diff --git a/app/controllers/admin/physical_tickets_controller.rb b/app/controllers/admin/physical_tickets_controller.rb index 0fb26ad8..6c0414c6 100644 --- a/app/controllers/admin/physical_tickets_controller.rb +++ b/app/controllers/admin/physical_tickets_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class PhysicalTicketsController < Admin::BaseController before_action :authenticate_user! diff --git a/app/controllers/admin/programs_controller.rb b/app/controllers/admin/programs_controller.rb index 3d9f66d8..1162f2f6 100644 --- a/app/controllers/admin/programs_controller.rb +++ b/app/controllers/admin/programs_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class ProgramsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -14,7 +16,7 @@ module Admin send_mail_on_schedule_public = @program.notify_on_schedule_public? event_schedules_count_was = @program.event_schedules.count - if @program.update_attributes(program_params) + if @program.update(program_params) ConferenceScheduleUpdateMailJob.perform_later(@conference) if send_mail_on_schedule_public respond_to do |format| format.html do @@ -30,7 +32,7 @@ module Admin flash.now[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}." render :new end - format.js { render json: { errors: "The selected schedule couldn't be updated #{@program.errors.to_a.join('. ')}" }, status: 422 } + format.js { render json: { errors: "The selected schedule couldn't be updated #{@program.errors.to_a.join('. ')}" }, status: :unprocessable_entity } end end end diff --git a/app/controllers/admin/questions_controller.rb b/app/controllers/admin/questions_controller.rb index 71abc7a1..25e3d90a 100644 --- a/app/controllers/admin/questions_controller.rb +++ b/app/controllers/admin/questions_controller.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + module Admin class QuestionsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource through: :conference, except: [:new, :create] + load_and_authorize_resource through: :conference, except: %i[new create] def index authorize! :index, Question.new(conference_id: @conference.id) @@ -24,9 +26,7 @@ module Admin @question.conference_id = @conference.id authorize! :create, @question - if @question.question_type_id == QuestionType.find_by(title: 'Yes/No').id - @question.answers = [Answer.find_by(title: 'Yes'), Answer.find_by(title: 'No')] - end + @question.answers = [Answer.find_by(title: 'Yes'), Answer.find_by(title: 'No')] if @question.question_type_id == QuestionType.find_by(title: 'Yes/No').id respond_to do |format| if @conference.save @@ -39,14 +39,12 @@ module Admin # GET questions/1/edit def edit - if @question.global - redirect_to admin_conference_questions_path(conference_id: @conference.short_title), error: 'Sorry, you cannot edit global questions. Create a new one.' - end + redirect_to admin_conference_questions_path(conference_id: @conference.short_title), error: 'Sorry, you cannot edit global questions. Create a new one.' if @question.global end # PUT questions/1 def update - if @question.update_attributes(question_params) + if @question.update(question_params) redirect_to admin_conference_questions_path(conference_id: @conference.short_title), notice: "Question '#{@question.title}' for #{@conference.short_title} successfully updated." else redirect_to admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed. #{@question.errors.full_messages.join('. ')}" @@ -56,7 +54,7 @@ module Admin # Update questions used for the conference def update_conference authorize! :update, Question.new(conference_id: @conference.id) - if @conference.update_attributes(conference_params) + if @conference.update(conference_params) redirect_to admin_conference_questions_path(conference_id: @conference.short_title), notice: "Questions for #{@conference.short_title} successfully updated." else redirect_to admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed." @@ -73,12 +71,9 @@ module Admin # Delete question and its answers begin Question.transaction do - @question.destroy - @question.answers.each do |a| - a.destroy - end - flash[:notice] = "Deleted question: #{@question.title} and its answers: #{@question.answers.map {|a| a.title}.join ','}" + @question.answers.each(&:destroy) + flash[:notice] = "Deleted question: #{@question.title} and its answers: #{@question.answers.map(&:title).join ','}" end rescue ActiveRecord::RecordInvalid flash[:error] = 'Could not delete question.' @@ -95,7 +90,7 @@ module Admin private def question_params - params.require(:question).permit(:title, :global, :answer_ids, :question_type_id, :conference_id, answers_attributes: [:id, :title]) + params.require(:question).permit(:title, :global, :answer_ids, :question_type_id, :conference_id, answers_attributes: %i[id title]) end def conference_params diff --git a/app/controllers/admin/registration_periods_controller.rb b/app/controllers/admin/registration_periods_controller.rb index 4e48c013..bb56d643 100644 --- a/app/controllers/admin/registration_periods_controller.rb +++ b/app/controllers/admin/registration_periods_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class RegistrationPeriodsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -21,11 +23,9 @@ module Admin end end - def edit - end + def edit; end - def show - end + def show; end def update @registration_period.assign_attributes(registration_period_params) diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index 475c18c8..cfe4ece2 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class RegistrationsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -17,9 +19,9 @@ module Admin def edit; end def update - @user.update_attributes(user_params) + @user.update(user_params) - @registration.update_attributes(registration_params) + @registration.update(registration_params) if @registration.save redirect_to admin_conference_registrations_path(@conference.short_title), notice: "Successfully updated registration for #{@registration.user.email}!" diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb index b01a4bdc..879e214d 100644 --- a/app/controllers/admin/reports_controller.rb +++ b/app/controllers/admin/reports_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class ReportsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -13,9 +15,9 @@ module Admin 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) + .where('event_role = ? and program_id = ?', 'submitter', @program.id) + .where.not(user_id: attended_registrants_ids) + .includes(:user, :event) end end end diff --git a/app/controllers/admin/resources_controller.rb b/app/controllers/admin/resources_controller.rb index 89b068c3..2e290fb6 100644 --- a/app/controllers/admin/resources_controller.rb +++ b/app/controllers/admin/resources_controller.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + module Admin class ResourcesController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource :resource, only: [:show, :edit, :update, :destroy] + load_and_authorize_resource :resource, only: %i[show edit update destroy] def index; end @@ -23,7 +25,7 @@ module Admin end def update - if @resource.update_attributes(resource_params) + if @resource.update(resource_params) redirect_to admin_conference_resources_path(conference_id: @conference.short_title), notice: 'Resource successfully updated.' else diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index ab7be841..ca455dce 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class RolesController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -34,7 +36,7 @@ module Admin def update role_name = @role.name - if @role.update_attributes(role_params) + if @role.update(role_params) url = if @track admin_conference_program_track_role_path(@conference.short_title, @track, @role.name) else diff --git a/app/controllers/admin/rooms_controller.rb b/app/controllers/admin/rooms_controller.rb index da7dfc57..af83d5cb 100644 --- a/app/controllers/admin/rooms_controller.rb +++ b/app/controllers/admin/rooms_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class RoomsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -24,7 +26,7 @@ module Admin end def update - if @room.update_attributes(room_params) + if @room.update(room_params) redirect_to admin_conference_venue_rooms_path(conference_id: @conference.short_title), notice: 'Room successfully updated.' else diff --git a/app/controllers/admin/schedules_controller.rb b/app/controllers/admin/schedules_controller.rb index 9f6c222b..77dd4eb6 100644 --- a/app/controllers/admin/schedules_controller.rb +++ b/app/controllers/admin/schedules_controller.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + module Admin class SchedulesController < Admin::BaseController # By authorizing 'conference' resource, we can ensure there will be no unauthorized access to # the schedule of a conference, which should not be accessed in the first place load_and_authorize_resource :conference, find_by: :short_title load_and_authorize_resource :program, through: :conference, singleton: true - load_and_authorize_resource :schedule, through: :program, except: [:new, :create] + load_and_authorize_resource :schedule, through: :program, except: %i[new create] load_resource :event_schedules, through: :schedule load_resource :selected_schedule, through: :program, singleton: true load_resource :venue, through: :conference, singleton: true diff --git a/app/controllers/admin/splashpages_controller.rb b/app/controllers/admin/splashpages_controller.rb index 5f04a67b..6b40d0d1 100644 --- a/app/controllers/admin/splashpages_controller.rb +++ b/app/controllers/admin/splashpages_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class SplashpagesController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -23,7 +25,7 @@ module Admin end def update - if @splashpage.update_attributes(splashpage_params) + if @splashpage.update(splashpage_params) redirect_to admin_conference_splashpage_path, notice: 'Splashpage successfully updated.' else diff --git a/app/controllers/admin/sponsors_controller.rb b/app/controllers/admin/sponsors_controller.rb index 909c2d7c..d0dc9406 100644 --- a/app/controllers/admin/sponsors_controller.rb +++ b/app/controllers/admin/sponsors_controller.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + module Admin class SponsorsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title load_and_authorize_resource :sponsor, through: :conference - before_action :sponsorship_level_required, only: [:index, :new] + before_action :sponsorship_level_required, only: %i[index new] def index authorize! :index, Sponsor.new(conference_id: @conference.id) @@ -26,9 +28,10 @@ module Admin end def update - if @sponsor.update_attributes(sponsor_params) + if @sponsor.update(sponsor_params) redirect_to admin_conference_sponsors_path( - conference_id: @conference.short_title), + conference_id: @conference.short_title + ), notice: 'Sponsor successfully updated.' else flash.now[:error] = "Update sponsor failed: #{@sponsor.errors.full_messages.join('. ')}." diff --git a/app/controllers/admin/sponsorship_levels_controller.rb b/app/controllers/admin/sponsorship_levels_controller.rb index 714b1ed5..35882e1d 100644 --- a/app/controllers/admin/sponsorship_levels_controller.rb +++ b/app/controllers/admin/sponsorship_levels_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class SponsorshipLevelsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -25,9 +27,10 @@ module Admin end def update - if @sponsorship_level.update_attributes(sponsorship_level_params) + if @sponsorship_level.update(sponsorship_level_params) redirect_to admin_conference_sponsorship_levels_path( - conference_id: @conference.short_title), + conference_id: @conference.short_title + ), notice: 'Sponsorship level successfully updated.' else flash.now[:error] = "Update Sponsorship level failed: #{@sponsorship_level.errors.full_messages.join('. ')}." diff --git a/app/controllers/admin/targets_controller.rb b/app/controllers/admin/targets_controller.rb index a04925b7..a7696ad7 100644 --- a/app/controllers/admin/targets_controller.rb +++ b/app/controllers/admin/targets_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class TargetsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -23,7 +25,7 @@ module Admin def edit; end def update - if @target.update_attributes(target_params) + if @target.update(target_params) redirect_to admin_conference_targets_path(conference_id: @conference.short_title), notice: 'Target successfully updated.' else diff --git a/app/controllers/admin/ticket_scannings_controller.rb b/app/controllers/admin/ticket_scannings_controller.rb index 488f28a1..f6637111 100644 --- a/app/controllers/admin/ticket_scannings_controller.rb +++ b/app/controllers/admin/ticket_scannings_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class TicketScanningsController < Admin::BaseController before_action :authenticate_user! diff --git a/app/controllers/admin/tickets_controller.rb b/app/controllers/admin/tickets_controller.rb index cf6e0f80..b19032a9 100644 --- a/app/controllers/admin/tickets_controller.rb +++ b/app/controllers/admin/tickets_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class TicketsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -27,7 +29,7 @@ module Admin def edit; end def update - if @ticket.update_attributes(ticket_params) + if @ticket.update(ticket_params) redirect_to admin_conference_tickets_path(conference_id: @conference.short_title), notice: 'Ticket successfully updated.' else diff --git a/app/controllers/admin/tracks_controller.rb b/app/controllers/admin/tracks_controller.rb index 4692f9a1..6e8e02db 100644 --- a/app/controllers/admin/tracks_controller.rb +++ b/app/controllers/admin/tracks_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class TracksController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -54,7 +56,7 @@ module Admin def edit; end def update - if @track.update_attributes(track_params) + if @track.update(track_params) redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title), notice: 'Track successfully updated.' else @@ -120,13 +122,13 @@ module Admin end def update_selected_schedule - if @track.update_attributes(params.require(:track).permit(:selected_schedule_id)) + if @track.update(params.require(:track).permit(:selected_schedule_id)) respond_to do |format| format.js { render json: {} } end else respond_to do |format| - format.js { render json: { errors: "The selected schedule couldn't be updated #{@track.errors.to_a.join('. ')}" }, status: 422 } + format.js { render json: { errors: "The selected schedule couldn't be updated #{@track.errors.to_a.join('. ')}" }, status: :unprocessable_entity } end end end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index b67792e1..4b3e7cd9 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class UsersController < Admin::BaseController load_and_authorize_resource @@ -36,9 +38,9 @@ module Admin # Variable @show_attributes holds the attributes that are visible for the 'show' action # If you want to change the attributes that are shown in the 'show' action of users # add/remove the attributes in the following string array - @show_attributes = %w(name email username nickname affiliation biography registered attended roles created_at + @show_attributes = %w[name email username nickname affiliation biography registered attended roles created_at updated_at sign_in_count current_sign_in_at last_sign_in_at - current_sign_in_ip last_sign_in_ip) + current_sign_in_ip last_sign_in_ip] end def update @@ -49,7 +51,7 @@ module Admin end end - if @user.update_attributes(user_params) + if @user.update(user_params) redirect_to admin_users_path, notice: "Updated #{@user.name} (#{@user.email})!" + message else redirect_to admin_users_path, error: "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}." diff --git a/app/controllers/admin/venue_commercials_controller.rb b/app/controllers/admin/venue_commercials_controller.rb index 20117e15..e07c04d3 100644 --- a/app/controllers/admin/venue_commercials_controller.rb +++ b/app/controllers/admin/venue_commercials_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class VenueCommercialsController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -38,7 +40,7 @@ module Admin def render_commercial result = Commercial.render_from_url(params[:url]) if result[:error] - render text: result[:error], status: 400 + render text: result[:error], status: :bad_request else render text: result[:html] end diff --git a/app/controllers/admin/venues_controller.rb b/app/controllers/admin/venues_controller.rb index ba8531ab..17ba4c99 100644 --- a/app/controllers/admin/venues_controller.rb +++ b/app/controllers/admin/venues_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class VenuesController < Admin::BaseController load_and_authorize_resource :conference, find_by: :short_title @@ -23,7 +25,7 @@ module Admin end def update - if @venue.update_attributes(venue_params) + if @venue.update(venue_params) redirect_to admin_conference_venue_path(conference_id: @conference.short_title), notice: 'Venue was successfully updated.' else diff --git a/app/controllers/admin/versions_controller.rb b/app/controllers/admin/versions_controller.rb index 5f18da1c..d9937668 100644 --- a/app/controllers/admin/versions_controller.rb +++ b/app/controllers/admin/versions_controller.rb @@ -1,14 +1,14 @@ +# frozen_string_literal: true + module Admin class VersionsController < Admin::BaseController load_resource :conference, find_by: :short_title, only: :index load_and_authorize_resource class: PaperTrail::Version def index - @conferences_with_role = current_user.is_admin? ? Conference.pluck(:short_title) : Conference.with_role([:organizer, :cfp, :info_desk], current_user).pluck(:short_title) + @conferences_with_role = current_user.is_admin? ? Conference.pluck(:short_title) : Conference.with_role(%i[organizer cfp info_desk], current_user).pluck(:short_title) - if current_user.has_cached_role? :organization_admin, :any - @conferences_with_role = Organization.with_role('organization_admin', current_user).map { |org| org.conferences.pluck :short_title }.flatten - end + @conferences_with_role = Organization.with_role('organization_admin', current_user).map { |org| org.conferences.pluck :short_title }.flatten if current_user.has_cached_role? :organization_admin, :any @conferences_with_role.uniq! return if @conference.blank? @@ -16,7 +16,7 @@ module Admin end def revert_attribute - if params[:attribute] && @version.changeset.reject{ |_, values| values[0].blank? && values[1].blank? }.keys.include?(params[:attribute]) + if params[:attribute] && @version.changeset.reject { |_, values| values[0].blank? && values[1].blank? }.keys.include?(params[:attribute]) if @version.item[params[:attribute]] == @version.changeset[params[:attribute]][0] flash[:error] = 'The item is already in the state that you are trying to revert it back to' diff --git a/app/controllers/admin/volunteers_controller.rb b/app/controllers/admin/volunteers_controller.rb index aefa682a..b0b85ffc 100644 --- a/app/controllers/admin/volunteers_controller.rb +++ b/app/controllers/admin/volunteers_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class VolunteersController < Admin::BaseController include VolunteersHelper @@ -24,7 +26,7 @@ module Admin end def update - if @conference.update_attributes(conference_params) + if @conference.update(conference_params) redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: 'Volunteering options were successfully updated.' else redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]), error: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}" diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index aaa6f130..619901b2 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api class BaseController < ActionController::Base protect_from_forgery with: :exception diff --git a/app/controllers/api/v1/conferences_controller.rb b/app/controllers/api/v1/conferences_controller.rb index 60578587..45976e97 100644 --- a/app/controllers/api/v1/conferences_controller.rb +++ b/app/controllers/api/v1/conferences_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class ConferencesController < Api::BaseController diff --git a/app/controllers/api/v1/events_controller.rb b/app/controllers/api/v1/events_controller.rb index 1cb01ad9..0577eb41 100644 --- a/app/controllers/api/v1/events_controller.rb +++ b/app/controllers/api/v1/events_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class EventsController < Api::BaseController @@ -10,9 +12,7 @@ module Api def index events = Event.includes(:track, :event_type, event_users: :user) - if @conference - events = events.where(program: @conference.program) - end + events = events.where(program: @conference.program) if @conference respond_with events.confirmed, callback: params[:callback] end diff --git a/app/controllers/api/v1/rooms_controller.rb b/app/controllers/api/v1/rooms_controller.rb index ecc959fa..56eb7f28 100644 --- a/app/controllers/api/v1/rooms_controller.rb +++ b/app/controllers/api/v1/rooms_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class RoomsController < Api::BaseController diff --git a/app/controllers/api/v1/speakers_controller.rb b/app/controllers/api/v1/speakers_controller.rb index 2706d2e9..dbb0f697 100644 --- a/app/controllers/api/v1/speakers_controller.rb +++ b/app/controllers/api/v1/speakers_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class SpeakersController < Api::BaseController @@ -9,13 +11,13 @@ module Api def index if @conference - users = User.joins(event_users: { event: { program: :conference} }) + users = User.joins(event_users: { event: { program: :conference } }) users = users.where(conferences: { short_title: @conference.short_title }) else users = User.joins(:event_users) end - users = users.where(event_users: {event_role: :speaker}).uniq + users = users.where(event_users: { event_role: :speaker }).uniq render json: users, each_serializer: SpeakerSerializer, callback: params['callback'] end end diff --git a/app/controllers/api/v1/tracks_controller.rb b/app/controllers/api/v1/tracks_controller.rb index 48a9450f..49d8094b 100644 --- a/app/controllers/api/v1/tracks_controller.rb +++ b/app/controllers/api/v1/tracks_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class TracksController < Api::BaseController diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7421a0f0..8f8a5591 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationController < ActionController::Base before_action :set_paper_trail_whodunnit include ApplicationHelper @@ -11,24 +13,24 @@ class ApplicationController < ActionController::Base def store_location # store last url - this is needed for post-login redirect to whatever the user last visited. return unless request.get? - if (request.path != '/accounts/sign_in' && - request.path != '/accounts/sign_up' && - request.path != '/accounts/password/new' && - request.path != '/accounts/password/edit' && - request.path != '/accounts/confirmation' && - request.path != '/accounts/sign_out' && - request.path != '/users/ichain_registration/ichain_sign_up' && - !request.path.starts_with?(Devise.ichain_base_url) && - !request.xhr?) # don't store ajax calls + if request.path != '/accounts/sign_in' && + request.path != '/accounts/sign_up' && + request.path != '/accounts/password/new' && + request.path != '/accounts/password/edit' && + request.path != '/accounts/confirmation' && + request.path != '/accounts/sign_out' && + request.path != '/users/ichain_registration/ichain_sign_up' && + !request.path.starts_with?(Devise.ichain_base_url) && + !request.xhr? # don't store ajax calls session[:return_to] = request.fullpath end end def after_sign_in_path_for(_resource) if (can? :view, Conference) && - (!session[:return_to] || - session[:return_to] && - session[:return_to] == root_path) + (!session[:return_to] || + session[:return_to] && + session[:return_to] == root_path) admin_conferences_path else session[:return_to] || root_path @@ -61,10 +63,10 @@ class ApplicationController < ActionController::Base Rails.logger.debug('User is disabled!') sign_out(current_user) mail = User.admin.first ? User.admin.first.email : 'the admin!' - redirect_to User.ichain_logout_url, error: "This User is disabled. Please contact #{mail}!" + redirect_to User.ichain_logout_url, error: "This User is disabled. Please contact #{mail}!" end def not_found - raise ActionController::RoutingError.new('Not Found') + raise ActionController::RoutingError, 'Not Found' end end diff --git a/app/controllers/booths_controller.rb b/app/controllers/booths_controller.rb index f0457b88..a3f3c403 100644 --- a/app/controllers/booths_controller.rb +++ b/app/controllers/booths_controller.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + class BoothsController < ApplicationController before_action :authenticate_user! load_resource :conference, find_by: :short_title load_and_authorize_resource through: :conference - skip_authorize_resource only: [:withdraw, :confirm, :restart] + skip_authorize_resource only: %i[withdraw confirm restart] def index @booths = current_user.booths.where(conference_id: @conference.id).uniq @@ -34,7 +36,7 @@ class BoothsController < ApplicationController def update @url = conference_booth_path(@conference.short_title, @booth.id) - @booth.update_attributes(booth_params) + @booth.update(booth_params) if @booth.save redirect_to conference_booths_path, diff --git a/app/controllers/commercials_controller.rb b/app/controllers/commercials_controller.rb index 779b5d39..b83f0b7a 100644 --- a/app/controllers/commercials_controller.rb +++ b/app/controllers/commercials_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CommercialsController < ApplicationController load_resource :conference, find_by: :short_title before_action :set_event @@ -35,7 +37,7 @@ class CommercialsController < ApplicationController def render_commercial result = Commercial.render_from_url(params[:url]) if result[:error] - render text: result[:error], status: 400 + render text: result[:error], status: :bad_request else render text: result[:html] end diff --git a/app/controllers/conference_registrations_controller.rb b/app/controllers/conference_registrations_controller.rb index f2751a31..a3234607 100644 --- a/app/controllers/conference_registrations_controller.rb +++ b/app/controllers/conference_registrations_controller.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + class ConferenceRegistrationsController < ApplicationController - before_action :authenticate_user!, except: [:new, :create] + before_action :authenticate_user!, except: %i[new create] load_resource :conference, find_by: :short_title - authorize_resource :conference_registrations, class: Registration, except: [:new, :create] - before_action :set_registration, only: [:edit, :update, :destroy, :show] + authorize_resource :conference_registrations, class: Registration, except: %i[new create] + before_action :set_registration, only: %i[edit update destroy show] def new @registration = Registration.new(conference_id: @conference.id) @@ -54,9 +56,7 @@ class ConferenceRegistrationsController < ApplicationController ahoy.track 'Registered', title: 'New registration' # Sign in the new user - unless current_user - sign_in(@registration.user) - end + sign_in(@registration.user) unless current_user if @conference.tickets.any? && !current_user.supports?(@conference) redirect_to conference_tickets_path(@conference.short_title), @@ -73,7 +73,7 @@ class ConferenceRegistrationsController < ApplicationController end def update - if @registration.update_attributes(registration_params) + if @registration.update(registration_params) redirect_to conference_conference_registration_path(@conference.short_title), notice: 'Registration was successfully updated.' else @@ -110,14 +110,15 @@ class ConferenceRegistrationsController < ApplicationController def registration_params params.require(:registration) - .permit( - :conference_id, :arrival, :departure, - :volunteer, - vchoice_ids: [], qanswer_ids: [], - qanswers_attributes: [], - event_ids: [], - user_attributes: [ - :username, :email, :name, :password, :password_confirmation] - ) + .permit( + :conference_id, :arrival, :departure, + :volunteer, + vchoice_ids: [], qanswer_ids: [], + qanswers_attributes: [], + event_ids: [], + user_attributes: %i[ + username email name password password_confirmation + ] + ) end end diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index f46d29ae..021cc2d0 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ConferencesController < ApplicationController protect_from_forgery with: :null_session before_action :respond_to_options @@ -21,9 +23,7 @@ class ConferencesController < ApplicationController splashpage = @conference.splashpage - unless splashpage.present? - redirect_to admin_conference_splashpage_path(@conference.short_title) && return - end + redirect_to admin_conference_splashpage_path(@conference.short_title) && return if splashpage.blank? if splashpage.include_cfp cfps = @conference.program.cfps @@ -42,16 +42,10 @@ class ConferencesController < ApplicationController :room ).order('tracks.name') end - if splashpage.include_booths - @booths = @conference.confirmed_booths.order('title') - end - end - if splashpage.include_registrations || splashpage.include_tickets - @tickets = @conference.tickets.order('price_cents') - end - if splashpage.include_lodgings - @lodgings = @conference.lodgings.order('name') + @booths = @conference.confirmed_booths.order('title') if splashpage.include_booths end + @tickets = @conference.tickets.order('price_cents') if splashpage.include_registrations || splashpage.include_tickets + @lodgings = @conference.lodgings.order('name') if splashpage.include_lodgings if splashpage.include_sponsors @sponsorship_levels = @conference.sponsorship_levels.eager_load( :sponsors @@ -71,8 +65,10 @@ class ConferencesController < ApplicationController end def respond_to_options - respond_to do |format| - format.html { head :ok } - end if request.options? + if request.options? + respond_to do |format| + format.html { head :ok } + end + end end end diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index 3b8c9837..eaf5bb22 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ConfirmationsController < Devise::ConfirmationsController protected diff --git a/app/controllers/openids_controller.rb b/app/controllers/openids_controller.rb index 35bc0bae..3bccba2f 100644 --- a/app/controllers/openids_controller.rb +++ b/app/controllers/openids_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class OpenidsController < ApplicationController load_and_authorize_resource :user load_and_authorize_resource through: :user diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 2ebbdeeb..86713e8c 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class OrganizationsController < ApplicationController load_and_authorize_resource :organization diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index 322ed397..afa68635 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PaymentsController < ApplicationController before_action :authenticate_user! load_and_authorize_resource @@ -10,9 +12,7 @@ class PaymentsController < ApplicationController def new @total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false) - if @total_amount_to_pay.zero? - raise CanCan::AccessDenied.new('Nothing to pay for!', :new, Payment) - end + raise CanCan::AccessDenied.new('Nothing to pay for!', :new, Payment) if @total_amount_to_pay.zero? @unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference) end diff --git a/app/controllers/physical_tickets_controller.rb b/app/controllers/physical_tickets_controller.rb index c3cc40cb..afa83baf 100644 --- a/app/controllers/physical_tickets_controller.rb +++ b/app/controllers/physical_tickets_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PhysicalTicketsController < ApplicationController before_action :authenticate_user! load_resource :conference, find_by: :short_title diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 7ea81dc0..eb30d273 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + class ProposalsController < ApplicationController - before_action :authenticate_user!, except: [:show, :new, :create] + before_action :authenticate_user!, except: %i[show new create] load_resource :conference, find_by: :short_title load_resource :program, through: :conference, singleton: true load_and_authorize_resource :event, parent: false, through: :program # We authorize manually in these actions - skip_authorize_resource :event, only: [:confirm, :restart, :withdraw] + skip_authorize_resource :event, only: %i[confirm restart withdraw] def index @event = @program.events.new @@ -168,8 +170,7 @@ class ProposalsController < ApplicationController params.require(:event).permit(:event_type_id, :track_id, :difficulty_level_id, :title, :subtitle, :abstract, :description, :require_registration, :max_attendees, :language, - speaker_ids: [] - ) + speaker_ids: []) end def user_params diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index e020d217..2b022571 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RegistrationsController < Devise::RegistrationsController prepend_before_action :check_captcha, only: [:create] diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb index eb145730..13e10795 100644 --- a/app/controllers/schedules_controller.rb +++ b/app/controllers/schedules_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SchedulesController < ApplicationController load_and_authorize_resource protect_from_forgery with: :null_session @@ -8,11 +10,9 @@ class SchedulesController < ApplicationController def show @rooms = @conference.venue.rooms if @conference.venue schedules = @program.selected_event_schedules - unless schedules - redirect_to events_conference_schedule_path(@conference.short_title) - end + redirect_to events_conference_schedule_path(@conference.short_title) unless schedules - @events_xml = schedules.map(&:event).group_by{ |event| event.time.to_date } if schedules + @events_xml = schedules.map(&:event).group_by { |event| event.time.to_date } if schedules @dates = @conference.start_date..@conference.end_date @step_minutes = @program.schedule_interval.minutes @conf_start = @conference.start_hour @@ -20,7 +20,7 @@ class SchedulesController < ApplicationController # the schedule takes you to today if it is a date of the schedule @current_day = @conference.current_conference_day - @day = @current_day.present? ? @current_day : @dates.first + @day = @current_day.presence || @dates.first unless @current_day # the schedule takes you to the current time if it is beetween the start and the end time. @hour_column = @conference.hours_from_start_time(@conf_start, @conference.end_hour) @@ -37,7 +37,7 @@ class SchedulesController < ApplicationController @dates = @conference.start_date..@conference.end_date @events_schedules = @program.selected_event_schedules - @events_schedules = [] unless @events_schedules + @events_schedules ||= [] @unscheduled_events = @program.events.confirmed - @events_schedules.map(&:event) @@ -48,8 +48,10 @@ class SchedulesController < ApplicationController private def respond_to_options - respond_to do |format| - format.html { head :ok } - end if request.options? + if request.options? + respond_to do |format| + format.html { head :ok } + end + end end end diff --git a/app/controllers/subscriptions_controller.rb b/app/controllers/subscriptions_controller.rb index d5111835..e0e4daac 100644 --- a/app/controllers/subscriptions_controller.rb +++ b/app/controllers/subscriptions_controller.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + class SubscriptionsController < ApplicationController before_action :authenticate_user! load_resource :conference, find_by: :short_title - load_and_authorize_resource only: [:create, :destroy], through: :conference + load_and_authorize_resource only: %i[create destroy], through: :conference def create @subscription = current_user.subscriptions.build(conference_id: @conference.id) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 4221fb4e..dac4e34f 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TicketPurchasesController < ApplicationController before_action :authenticate_user! load_resource :conference, find_by: :short_title diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 94893c27..270b83b4 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TicketsController < ApplicationController before_action :authenticate_user! load_resource :conference, find_by: :short_title @@ -8,8 +10,6 @@ class TicketsController < ApplicationController def index; end def check_load_resource - if @tickets.empty? - redirect_to root_path, notice: "There are no tickets available for #{@conference.title}!" - end + redirect_to root_path, notice: "There are no tickets available for #{@conference.title}!" if @tickets.empty? end end diff --git a/app/controllers/tracks_controller.rb b/app/controllers/tracks_controller.rb index 6b584d22..6db26991 100644 --- a/app/controllers/tracks_controller.rb +++ b/app/controllers/tracks_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TracksController < ApplicationController load_resource :conference, find_by: :short_title load_resource :program, through: :conference, singleton: true @@ -29,7 +31,7 @@ class TracksController < ApplicationController end def update - if @track.update_attributes(track_params) + if @track.update(track_params) redirect_to conference_program_tracks_path(conference_id: @conference.short_title), notice: 'Track request successfully updated.' else diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 1d0400cd..b126f2c8 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + module Users class OmniauthCallbacksController < Devise::OmniauthCallbacksController - skip_before_filter :verify_authenticity_token + skip_before_action :verify_authenticity_token skip_authorization_check User.omniauth_providers.each do |provider| @@ -11,7 +13,7 @@ module Users def handle(provider) auth_hash = request.env['omniauth.auth'] - unless auth_hash.info.email.present? + if auth_hash.info.email.blank? flash[:error] = "Email field is missing in your #{provider} account" redirect_to new_user_registration_path return @@ -27,15 +29,13 @@ module Users begin user.save! - if openid.user != user - openid.user = user - end + openid.user = user if openid.user != user openid.save! sign_in user redirect_to request.env['omniauth.origin'] || root_path, notice: "#{user.email} signed in successfully with #{provider}" - rescue => e + rescue StandardError => e flash[:error] = e.message redirect_back_or_to new_user_registration_path end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6c027abd..9337f893 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UsersController < ApplicationController load_and_authorize_resource @@ -7,8 +9,7 @@ class UsersController < ApplicationController end # GET /users/1/edit - def edit - end + def edit; end # PATCH/PUT /users/1 def update @@ -22,8 +23,8 @@ class UsersController < ApplicationController private - # Only allow a trusted parameter "white list" through. - def user_params - params.require(:user).permit(:name, :biography, :nickname, :affiliation) - end + # Only allow a trusted parameter "white list" through. + def user_params + params.require(:user).permit(:name, :biography, :nickname, :affiliation) + end end diff --git a/app/helpers/admin/volunteers_helper.rb b/app/helpers/admin/volunteers_helper.rb index 6115f15b..0833c771 100644 --- a/app/helpers/admin/volunteers_helper.rb +++ b/app/helpers/admin/volunteers_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin module VolunteersHelper def can_manage_volunteers?(conference) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f0311c7a..8c461d8f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationHelper # Returns a string build from the start and end date of the given conference. # @@ -60,7 +62,7 @@ module ApplicationHelper end def difficulty_levels(conference) - all = conference.program.difficulty_levels.map {|t| t.title} + all = conference.program.difficulty_levels.map(&:title) first = all[0...-1] last = all[-1] ts = '' @@ -83,16 +85,14 @@ module ApplicationHelper # 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 + .reject { |_, values| values[0].blank? && values[1].blank? } + .keys.map { |key| key.gsub('_id', '').tr('_', ' ') }.join(', ') + .reverse.sub(',', ' dna ').reverse end def normalize_array_length(hashmap, length) hashmap.each_value do |value| - if value.length < length - value.fill(value[-1], value.length...length) - end + value.fill(value[-1], value.length...length) if value.length < length end end @@ -115,28 +115,26 @@ module ApplicationHelper other_event_schedules.each do |other_event_schedule| next unless other_event_schedule.event.confirmed? other_event_time_range = (other_event_schedule.start_time.strftime '%Y-%m-%d %H:%M')...(other_event_schedule.end_time.strftime '%Y-%m-%d %H:%M') - if (event_time_range.to_a & other_event_time_range.to_a).present? - concurrent_events << other_event_schedule.event - end + concurrent_events << other_event_schedule.event if (event_time_range.to_a & other_event_time_range.to_a).present? end concurrent_events end def speaker_links(event) - safe_join(event.speakers.map{ |speaker| link_to speaker.name, admin_user_path(speaker) }, ',') + safe_join(event.speakers.map { |speaker| link_to speaker.name, admin_user_path(speaker) }, ',') end def speaker_selector_input(form) - users = User.active.pluck(:id, :name, :username, :email).map { |user| [user[0], user[1].blank? ? user[2] : user[1], user[2], user[3]] }.sort_by { |user| user[1].downcase } + users = User.active.pluck(:id, :name, :username, :email).map { |user| [user[0], user[1].presence || user[2], user[2], user[3]] }.sort_by { |user| user[1].downcase } form.input :speakers, as: :select, - collection: options_for_select(users.map {|user| ["#{user[1]} (#{user[2]}) #{user[3]}", user[0]]}, @event.speakers.map(&:id)), + collection: options_for_select(users.map { |user| ["#{user[1]} (#{user[2]}) #{user[3]}", user[0]] }, @event.speakers.map(&:id)), include_blank: false, label: 'Speakers', input_html: { class: 'select-help-toggle', multiple: 'true' } end def responsibles_selector_input(form) - users = User.active.pluck(:id, :name, :username, :email).map { |user| [user[0], user[1].blank? ? user[2] : user[1], user[2], user[3]] }.sort_by { |user| user[1].downcase } + users = User.active.pluck(:id, :name, :username, :email).map { |user| [user[0], user[1].presence || user[2], user[2], user[3]] }.sort_by { |user| user[1].downcase } form.input :responsibles, as: :select, - collection: options_for_select(users.map {|user| ["#{user[1]} (#{user[2]}) #{user[3]}", user[0]]}, @booth.responsibles.map(&:id)), + collection: options_for_select(users.map { |user| ["#{user[1]} (#{user[2]}) #{user[3]}", user[0]] }, @booth.responsibles.map(&:id)), include_blank: false, label: 'Responsibles', input_html: { class: 'select-help-toggle', multiple: 'true' }, hint: 'The people responsible for the booth. You can only select existing users.' end @@ -154,9 +152,7 @@ module ApplicationHelper end def rescheduling_hint(affected_event_count) - if affected_event_count > 0 - "You have #{affected_event_count} scheduled #{'event'.pluralize(affected_event_count)}. Changing the conference hours will unschedule those scheduled outside the conference hours." - end + "You have #{affected_event_count} scheduled #{'event'.pluralize(affected_event_count)}. Changing the conference hours will unschedule those scheduled outside the conference hours." if affected_event_count > 0 end ## diff --git a/app/helpers/conference_helper.rb b/app/helpers/conference_helper.rb index 20ef6ba4..d6629814 100644 --- a/app/helpers/conference_helper.rb +++ b/app/helpers/conference_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ConferenceHelper # Return true if only call_for_papers or call_for_tracks or call_for_booths is open def one_call_open(*calls) @@ -6,7 +8,7 @@ module ConferenceHelper # Return true if exactly two of those calls are open: call_for_papers , call_for_tracks , call_for_booths def two_calls_open(*calls) - calls.count{ |call| call.try(:open?) } == 2 + calls.count { |call| call.try(:open?) } == 2 end # URL for sponsorship emails diff --git a/app/helpers/date_time_helper.rb b/app/helpers/date_time_helper.rb index a8e4f660..7e15e930 100644 --- a/app/helpers/date_time_helper.rb +++ b/app/helpers/date_time_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DateTimeHelper ## # Includes functions related to date or time manipulations diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 1140898b..5e67e0a9 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module EventsHelper ## # Includes functions related to events diff --git a/app/helpers/format_helper.rb b/app/helpers/format_helper.rb index a41c584e..63b6a367 100644 --- a/app/helpers/format_helper.rb +++ b/app/helpers/format_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FormatHelper ## # Includes functions related to formatting (like adding classes, colors) @@ -44,24 +46,23 @@ module FormatHelper def target_progress_color(progress) progress = progress.to_i result = - case - when progress >= 90 then 'green' - when progress < 90 && progress >= 80 then 'orange' - else 'red' - end + if progress >= 90 then 'green' + elsif progress < 90 && progress >= 80 then 'orange' + else 'red' + end result end def days_left_color(days_left) days_left = days_left.to_i - if days_left > 30 - result = 'green' - elsif days_left < 30 && days_left > 10 - result = 'orange' - else - result = 'red' - end + result = if days_left > 30 + 'green' + elsif days_left < 30 && days_left > 10 + 'orange' + else + 'red' + end result end @@ -116,7 +117,7 @@ module FormatHelper end def word_pluralize(count, singular, plural = nil) - word = if (count == 1 || count =~ /^1(\.0+)?$/) + word = if count == 1 || count =~ /^1(\.0+)?$/ singular else plural || singular.pluralize @@ -134,7 +135,7 @@ module FormatHelper g = hexcolor[3..4].to_i(16) b = hexcolor[5..6].to_i(16) yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000 - (yiq >= 128) ? 'black' : 'white' + yiq >= 128 ? 'black' : 'white' end def td_height(rooms) @@ -178,17 +179,15 @@ module FormatHelper item_class = 'item' item_class += ' first' if number == 0 item_class += ' last' if number == (carousel_number - 1) - if (col && ((col / num_cols) == number)) || (!col && number == 0) - item_class += ' active' - end + item_class += ' active' if (col && ((col / num_cols) == number)) || (!col && number == 0) item_class end def selected_scheduled?(schedule) - (schedule == @selected_schedule) ? 'Yes' : 'No' + schedule == @selected_schedule ? 'Yes' : 'No' end - def markdown(text, escape_html=true) + def markdown(text, escape_html = true) return '' if text.nil? options = { @@ -200,7 +199,7 @@ module FormatHelper markdown.render(text).html_safe end - def markdown_hint(text='') + def markdown_hint(text = '') markdown("#{text} Please look at #{link_to '**Markdown Syntax**', 'https://daringfireball.net/projects/markdown/syntax', target: '_blank'} to format your text", false) end diff --git a/app/helpers/paths_helper.rb b/app/helpers/paths_helper.rb index 46e82900..cfedc2bd 100644 --- a/app/helpers/paths_helper.rb +++ b/app/helpers/paths_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module PathsHelper ## # Includes functions related to links or redirects diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 763a44c9..611bc6db 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module UsersHelper ## # Includes functions related to users @@ -12,10 +14,8 @@ module UsersHelper Devise.omniauth_providers.each do |provider| provider_key = "#{provider}_key" provider_secret = "#{provider}_secret" - unless Rails.application.secrets.send(provider_key).blank? || Rails.application.secrets.send(provider_secret).blank? - providers << provider - end - providers << provider if !ENV["OSEM_#{provider.upcase}_KEY"].blank? && !ENV["OSEM_#{provider.upcase}_SECRET"].blank? + providers << provider unless Rails.application.secrets.send(provider_key).blank? || Rails.application.secrets.send(provider_secret).blank? + providers << provider if ENV["OSEM_#{provider.upcase}_KEY"].present? && ENV["OSEM_#{provider.upcase}_SECRET"].present? end providers.uniq @@ -25,6 +25,6 @@ module UsersHelper # Outputs the roles of a user, including the conferences for which the user has the roles # Eg. organizer(oSC13, oSC14), cfp(oSC12, oSC13) def show_roles(roles) - roles.map{ |x| x[0].titleize + ' (' + x[1].join(', ') + ')' }.join ', ' + roles.map { |x| x[0].titleize + ' (' + x[1].join(', ') + ')' }.join ', ' end end diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb index 5788fe9d..50fadb49 100644 --- a/app/helpers/versions_helper.rb +++ b/app/helpers/versions_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module VersionsHelper ## # Groups functions related to change description @@ -119,10 +121,9 @@ module VersionsHelper end def event_change_description(version) - case - when version.event == 'create' then 'submitted new' + if version.event == 'create' then 'submitted new' - when version.changeset['state'] + elsif version.changeset['state'] case version.changeset['state'][1] when 'unconfirmed' then 'accepted' when 'withdrawn' then 'withdrew' diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index a009ace5..d92ffddc 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class ApplicationJob < ActiveJob::Base end diff --git a/app/jobs/conference_cfp_update_mail_job.rb b/app/jobs/conference_cfp_update_mail_job.rb index 7138bd59..43e74b12 100644 --- a/app/jobs/conference_cfp_update_mail_job.rb +++ b/app/jobs/conference_cfp_update_mail_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ConferenceCfpUpdateMailJob < ApplicationJob queue_as :default diff --git a/app/jobs/conference_date_update_mail_job.rb b/app/jobs/conference_date_update_mail_job.rb index 4218d22f..a50cc077 100644 --- a/app/jobs/conference_date_update_mail_job.rb +++ b/app/jobs/conference_date_update_mail_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ConferenceDateUpdateMailJob < ApplicationJob queue_as :default diff --git a/app/jobs/conference_registration_date_update_mail_job.rb b/app/jobs/conference_registration_date_update_mail_job.rb index ed7ee084..00864f7a 100644 --- a/app/jobs/conference_registration_date_update_mail_job.rb +++ b/app/jobs/conference_registration_date_update_mail_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ConferenceRegistrationDateUpdateMailJob < ApplicationJob queue_as :default diff --git a/app/jobs/conference_schedule_update_mail_job.rb b/app/jobs/conference_schedule_update_mail_job.rb index 02d03352..d500df2c 100644 --- a/app/jobs/conference_schedule_update_mail_job.rb +++ b/app/jobs/conference_schedule_update_mail_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ConferenceScheduleUpdateMailJob < ApplicationJob queue_as :default diff --git a/app/jobs/conference_venue_update_mail_job.rb b/app/jobs/conference_venue_update_mail_job.rb index 30203639..f53ef741 100644 --- a/app/jobs/conference_venue_update_mail_job.rb +++ b/app/jobs/conference_venue_update_mail_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ConferenceVenueUpdateMailJob < ApplicationJob queue_as :default diff --git a/app/jobs/event_comment_mail_job.rb b/app/jobs/event_comment_mail_job.rb index 36bc9294..bcc46ca7 100644 --- a/app/jobs/event_comment_mail_job.rb +++ b/app/jobs/event_comment_mail_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class EventCommentMailJob < ApplicationJob queue_as :default diff --git a/app/mailers/mailbot.rb b/app/mailers/mailbot.rb index 63f95a40..d33973aa 100644 --- a/app/mailers/mailbot.rb +++ b/app/mailers/mailbot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Mailbot < ActionMailer::Base def registration_mail(conference, user) mail(to: user.email, diff --git a/app/models/ability.rb b/app/models/ability.rb index d6b3ef21..d048311a 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Ability include CanCan::Ability @@ -15,7 +17,7 @@ class Ability # Abilities for not signed in users (guests) def not_signed_in - can [:index, :conferences], Organization + can %i[index conferences], Organization can [:index], Conference can [:show], Conference do |conference| conference.splashpage && conference.splashpage.public == true @@ -31,20 +33,16 @@ class Ability # can view Commercials of confirmed Events can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id) - can [:show, :create], User + can %i[show create], User unless ENV['OSEM_ICHAIN_ENABLED'] == 'true' - can :show, Registration do |registration| - registration.new_record? - end + can :show, Registration, &:new_record? can [:new, :create], Registration do |registration| conference = registration.conference conference.registration_open? && registration.new_record? && !conference.registration_limit_exceeded? end - can :show, Event do |event| - event.new_record? - end + can :show, Event, &:new_record? can [:new, :create], Event do |event| event.program.cfp_open? && event.new_record? @@ -78,8 +76,8 @@ class Ability can :index, Organization can :index, Ticket can :manage, TicketPurchase, user_id: user.id - can [:new, :create], Payment, user_id: user.id - can [:index, :show], PhysicalTicket, user: user + can %i[new create], Payment, user_id: user.id + can %i[index show], PhysicalTicket, user: user can [:new, :create], Booth do |booth| booth.new_record? && booth.conference.program.cfps.for_booths.try(:open?) @@ -89,7 +87,7 @@ class Ability booth.users.include?(user) end - can [:create, :destroy], Subscription, user_id: user.id + can %i[create destroy], Subscription, user_id: user.id can [:new, :create], Event do |event| event.program.cfp_open? && event.new_record? @@ -108,7 +106,7 @@ class Ability track.new_record? && track.program.cfps.for_tracks.try(:open?) end - can [:index, :show, :restart, :confirm, :withdraw], Track, submitter_id: user.id + can %i[index show restart confirm withdraw], Track, submitter_id: user.id can [:edit, :update], Track do |track| user == track.submitter && !(track.accepted? || track.confirmed?) diff --git a/app/models/admin_ability.rb b/app/models/admin_ability.rb index 603f499e..03a6470f 100644 --- a/app/models/admin_ability.rb +++ b/app/models/admin_ability.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AdminAbility include CanCan::Ability @@ -28,12 +30,12 @@ class AdminAbility conference.registration_open? && !conference.registration_limit_exceeded? || conference.program.speakers.confirmed.include?(user) end - can [:index, :admins], Organization + can %i[index admins], Organization can :index, Ticket can :manage, TicketPurchase, user_id: user.id - can [:new, :create], Payment, user_id: user.id + can %i[new create], Payment, user_id: user.id - can [:create, :destroy], Subscription, user_id: user.id + can %i[create destroy], Subscription, user_id: user.id can [:new, :create], Event do |event| event.program.cfp_open? && event.new_record? @@ -45,11 +47,11 @@ class AdminAbility can [:destroy], Openid can :access, Admin can :index, Commercial, commercialable_type: 'Conference' - cannot [:edit, :update, :destroy], Question, global: true + cannot %i[edit update destroy], Question, global: true # for admins can :manage, :all if user.is_admin # even admin cannot create new users with ICHAIN enabled - cannot [:new, :create], User if ENV['OSEM_ICHAIN_ENABLED'] == 'true' + cannot %i[new create], User if ENV['OSEM_ICHAIN_ENABLED'] == 'true' cannot :revert_object, PaperTrail::Version do |version| (version.event == 'create' && %w[Conference User Event].include?(version.item_type)) end @@ -67,9 +69,7 @@ class AdminAbility end # Prevent requests for tracks from being destroyed - cannot :destroy, Track do |track| - track.self_organized? - end + cannot :destroy, Track, &:self_organized? # Can't accept a booth when booth_limit is reached cannot :accept, Booth do |booth| conference = booth.conference @@ -92,10 +92,10 @@ class AdminAbility org_ids_for_organization_admin = Organization.with_role(:organization_admin, user).pluck(:id) conf_ids_for_organization_admin = Conference.where(organization_id: org_ids_for_organization_admin).pluck(:id) - can [:read, :update, :destroy, :assign_org_admins, :unassign_org_admins, :admins], Organization, id: org_ids_for_organization_admin + can %i[read update destroy assign_org_admins unassign_org_admins admins], Organization, id: org_ids_for_organization_admin can :new, Conference can :manage, Conference, organization_id: org_ids_for_organization_admin - can [:index, :show], Role + can %i[index show], Role signed_in_with_organizer_role(user, conf_ids_for_organization_admin) end @@ -108,7 +108,7 @@ class AdminAbility track_ids = Track.joins(:program).where('programs.conference_id IN (?)', conf_ids).pluck(:id) can :manage, Resource, conference_id: conf_ids - can [:read, :update, :destroy], Conference, id: conf_ids + can %i[read update destroy], Conference, id: conf_ids can :manage, Splashpage, conference_id: conf_ids can :manage, Contact, conference_id: conf_ids can :manage, EmailSettings, conference_id: conf_ids @@ -163,8 +163,8 @@ class AdminAbility role.resource_type == 'Track' && (track_ids.include? role.resource_id) end - can [:index, :revert_object, :revert_attribute], PaperTrail::Version, item_type: 'User' - can [:index, :revert_object, :revert_attribute], PaperTrail::Version, conference_id: conf_ids + can %i[index revert_object revert_attribute], PaperTrail::Version, item_type: 'User' + can %i[index revert_object revert_attribute], PaperTrail::Version, conference_id: conf_ids end def signed_in_with_cfp_role(user) @@ -174,7 +174,7 @@ class AdminAbility can :show, Conference do |conf| conf_ids_for_cfp.include?(conf.id) end - can [:index, :show, :update], Resource, conference_id: conf_ids_for_cfp + can %i[index show update], Resource, conference_id: conf_ids_for_cfp can :manage, Booth, conference_id: conf_ids_for_cfp can :manage, Event, program: { conference_id: conf_ids_for_cfp } can :manage, EventType, program: { conference_id: conf_ids_for_cfp } @@ -203,7 +203,7 @@ class AdminAbility (Conference.with_role(:cfp, user).pluck(:id).include? role.resource_id) end - can [:index, :revert_object, :revert_attribute], PaperTrail::Version, + can %i[index revert_object revert_attribute], PaperTrail::Version, item_type: %w[Event EventType Track DifficultyLevel EmailSettings Room Cfp Program Comment], conference_id: conf_ids_for_cfp can [:index, :revert_object, :revert_attribute], PaperTrail::Version, ["item_type = 'Commercial' AND conference_id IN (?) AND (object LIKE '%Event%' OR object_changes LIKE '%Event%')", conf_ids_for_cfp] do |version| @@ -219,7 +219,7 @@ class AdminAbility can :show, Conference do |conf| conf_ids_for_info_desk.include?(conf.id) end - can [:index, :show, :update], Resource, conference_id: conf_ids_for_info_desk + can %i[index show update], Resource, conference_id: conf_ids_for_info_desk can :manage, Registration, conference_id: conf_ids_for_info_desk can :manage, Question, conference_id: conf_ids_for_info_desk can :manage, Question do |question| @@ -240,7 +240,7 @@ class AdminAbility role.resource_type == 'Conference' && role.name == 'info_desk' && (Conference.with_role(:info_desk, user).pluck(:id).include? role.resource_id) end - can [:index, :revert_object, :revert_attribute], PaperTrail::Version, item_type: 'Registration', conference_id: conf_ids_for_info_desk + can %i[index revert_object revert_attribute], PaperTrail::Version, item_type: 'Registration', conference_id: conf_ids_for_info_desk end def signed_in_with_volunteers_coordinator_role(user) @@ -250,7 +250,7 @@ class AdminAbility can :show, Conference do |conf| conf_ids_for_volunteers_coordinator.include?(conf.id) end - can [:index, :show, :update], Resource, conference_id: conf_ids_for_volunteers_coordinator + can %i[index show update], Resource, conference_id: conf_ids_for_volunteers_coordinator can :manage, Vposition, conference_id: conf_ids_for_volunteers_coordinator can :manage, Vday, conference_id: conf_ids_for_volunteers_coordinator @@ -286,9 +286,7 @@ class AdminAbility can :manage, Track, id: track_ids_for_track_organizer - cannot [:edit, :update], Track do |track| - track.self_organized_and_accepted_or_confirmed? - end + cannot %i[edit update], Track, &:self_organized_and_accepted_or_confirmed? # Show Roles in the admin sidebar and allow authorization of the index action can [:index, :show], Role do |role| diff --git a/app/models/ahoy/event.rb b/app/models/ahoy/event.rb index 74758c47..cf693623 100644 --- a/app/models/ahoy/event.rb +++ b/app/models/ahoy/event.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Ahoy class Event < ApplicationRecord self.table_name = 'ahoy_events' diff --git a/app/models/answer.rb b/app/models/answer.rb index 6d1bca3c..abada979 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Answer < ApplicationRecord has_many :qanswers has_many :questions, through: :qanswers diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 10a4cba8..71fbba5b 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end diff --git a/app/models/booth.rb b/app/models/booth.rb index e64a230a..7d2b4098 100644 --- a/app/models/booth.rb +++ b/app/models/booth.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Booth < ApplicationRecord include ActiveRecord::Transitions has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id } @@ -41,28 +43,28 @@ class Booth < ApplicationRecord state :confirmed event :restart do - transitions to: :new, from: [:withdrawn, :rejected, :canceled] + transitions to: :new, from: %i[withdrawn rejected canceled] end event :withdraw do - transitions to: :withdrawn, from: [:new, :to_accept, :accepted, :to_reject, :rejected, :confirmed] + transitions to: :withdrawn, from: %i[new to_accept accepted to_reject rejected confirmed] end event :confirm do transitions to: :confirmed, from: [:accepted] end event :to_accept do - transitions to: :to_accept, from: [:new, :to_reject] + transitions to: :to_accept, from: %i[new to_reject] end event :to_reject do - transitions to: :to_reject, from: [:new, :to_accept] + transitions to: :to_reject, from: %i[new to_accept] end event :accept do - transitions to: :accepted, from: [:new, :to_accept] + transitions to: :accepted, from: %i[new to_accept] end event :reject do - transitions to: :rejected, from: [:new, :to_reject] + transitions to: :rejected, from: %i[new to_reject] end event :cancel do - transitions to: :canceled, from: [:accepted, :rejected, :to_accept, :to_reject, :confirmed] + transitions to: :canceled, from: %i[accepted rejected to_accept to_reject confirmed] end end diff --git a/app/models/booth_request.rb b/app/models/booth_request.rb index f57c712e..5cce46a1 100644 --- a/app/models/booth_request.rb +++ b/app/models/booth_request.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class BoothRequest < ApplicationRecord belongs_to :booth belongs_to :user diff --git a/app/models/campaign.rb b/app/models/campaign.rb index 103274a0..3e02ccb4 100644 --- a/app/models/campaign.rb +++ b/app/models/campaign.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Campaign < ApplicationRecord validates :name, :utm_campaign, presence: true @@ -66,11 +68,11 @@ class Campaign < ApplicationRecord # * +Hash+ -> parameter => value def get_parameters conditions = {} - conditions[:utm_source] = self[:utm_source] unless self[:utm_source].blank? - conditions[:utm_medium] = self[:utm_medium] unless self[:utm_medium].blank? - conditions[:utm_term] = self[:utm_term] unless self[:utm_term].blank? - conditions[:utm_content] = self[:utm_content] unless self[:utm_content].blank? - conditions[:utm_campaign] = self[:utm_campaign] unless self[:utm_campaign].blank? + conditions[:utm_source] = self[:utm_source] if self[:utm_source].present? + conditions[:utm_medium] = self[:utm_medium] if self[:utm_medium].present? + conditions[:utm_term] = self[:utm_term] if self[:utm_term].present? + conditions[:utm_content] = self[:utm_content] if self[:utm_content].present? + conditions[:utm_campaign] = self[:utm_campaign] if self[:utm_campaign].present? conditions end end diff --git a/app/models/cfp.rb b/app/models/cfp.rb index 5105a6bd..8014df18 100644 --- a/app/models/cfp.rb +++ b/app/models/cfp.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # cannot delete program if there are events submitted class Cfp < ApplicationRecord - TYPES = %w(events booths tracks).freeze + TYPES = %w[events booths tracks].freeze has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id } belongs_to :program @@ -27,11 +29,11 @@ class Cfp < ApplicationRecord # * +True+ -> If cfp dates is updated and all other parameters are set # * +False+ -> Either cfp date is not updated or one or more parameter is not set def notify_on_cfp_date_update? - !end_date.blank? && !start_date.blank?\ + end_date.present? && start_date.present?\ && (start_date_changed? || end_date_changed?)\ && program.conference.email_settings.send_on_cfp_dates_updated\ - && !program.conference.email_settings.cfp_dates_updated_subject.blank?\ - && !program.conference.email_settings.cfp_dates_updated_body.blank? + && program.conference.email_settings.cfp_dates_updated_subject.present?\ + && program.conference.email_settings.cfp_dates_updated_body.present? end ## @@ -106,20 +108,22 @@ class Cfp < ApplicationRecord private def before_end_of_conference - if program && 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})") + .add(:end_date, "can't be after the conference end date (#{program.conference.end_date})") end - if program && 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})") + .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 + if start_date && end_date && start_date > end_date + errors + .add(:start_date, "can't be after the end date") + end end def conference_id diff --git a/app/models/comment.rb b/app/models/comment.rb index 535eea57..38a1c791 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,19 +1,21 @@ +# frozen_string_literal: true + class Comment < ApplicationRecord - acts_as_nested_set scope: %i(commentable_id commentable_type) + acts_as_nested_set scope: %i[commentable_id commentable_type] validates :body, presence: true validates :user, presence: true after_create :send_notification # NOTE: install the acts_as_votable plugin if you # want user to vote on the quality of comments. - #acts_as_votable + # acts_as_votable belongs_to :commentable, counter_cache: true, polymorphic: true # NOTE: Comments belong to a user belongs_to :user - has_paper_trail on: %i(create destroy), meta: { conference_id: :conference_id } + has_paper_trail on: %i[create destroy], meta: { conference_id: :conference_id } # Helper class method that allows you to build a comment # by passing a commentable object, a user_id, and comment text @@ -25,7 +27,7 @@ class Comment < ApplicationRecord user_id: user_id end - #helper method to check if a comment has children + # helper method to check if a comment has children def has_children? children.any? end diff --git a/app/models/commercial.rb b/app/models/commercial.rb index ad9597e4..2b4e1621 100644 --- a/app/models/commercial.rb +++ b/app/models/commercial.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Commercial < ApplicationRecord require 'oembed' @@ -6,7 +8,7 @@ class Commercial < ApplicationRecord has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id } validates :url, presence: true, uniqueness: { scope: :commercialable } - validates :url, format: URI::regexp(%w(http https)) + validates :url, format: URI.regexp(%w[http https]) validate :valid_url @@ -36,9 +38,7 @@ class Commercial < ApplicationRecord errors[:no_event] << id && next unless event commercial = event.commercials.new(url: url) - unless commercial.save - errors[:validation_errors] << "Could not create commercial for event with ID #{event.id} (" + commercial.errors.full_messages.to_sentence + ')' - end + errors[:validation_errors] << "Could not create commercial for event with ID #{event.id} (" + commercial.errors.full_messages.to_sentence + ')' unless commercial.save end errors end @@ -47,9 +47,7 @@ class Commercial < ApplicationRecord def valid_url result = Commercial.render_from_url(url) - if result[:error] - errors.add(:base, result[:error]) - end + errors.add(:base, result[:error]) if result[:error] end def self.register_provider @@ -58,12 +56,12 @@ class Commercial < ApplicationRecord speakerdeck << 'http://speakerdeck.com/*' OEmbed::Providers.register( - OEmbed::Providers::Youtube, - OEmbed::Providers::Vimeo, - OEmbed::Providers::Slideshare, - OEmbed::Providers::Flickr, - OEmbed::Providers::Instagram, - speakerdeck + OEmbed::Providers::Youtube, + OEmbed::Providers::Vimeo, + OEmbed::Providers::Slideshare, + OEmbed::Providers::Flickr, + OEmbed::Providers::Instagram, + speakerdeck ) end diff --git a/app/models/concerns/revision_count.rb b/app/models/concerns/revision_count.rb index 71789f34..4b395367 100644 --- a/app/models/concerns/revision_count.rb +++ b/app/models/concerns/revision_count.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module RevisionCount extend ActiveSupport::Concern diff --git a/app/models/conference.rb b/app/models/conference.rb index 81e9ec32..50594039 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Conference < ApplicationRecord include RevisionCount require 'uri' @@ -12,7 +14,7 @@ class Conference < ApplicationRecord belongs_to :organization - has_paper_trail ignore: %i(updated_at guid revision events_per_week), meta: { conference_id: :id } + has_paper_trail ignore: %i[updated_at guid revision events_per_week], meta: { conference_id: :id } has_and_belongs_to_many :questions @@ -91,7 +93,7 @@ class Conference < ApplicationRecord after_create :create_free_ticket after_update :delete_event_schedules - enum ticket_layout: [:portrait, :landscape] + enum ticket_layout: %i[portrait landscape] ## # Checks if the user is registered to the conference @@ -101,7 +103,7 @@ class Conference < ApplicationRecord # ====Returns # * +false+ -> If the user is registered # * +true+ - If the user isn't registered - def user_registered? user + def user_registered?(user) user.present? && registrations.where(user_id: user.id).count > 0 end @@ -112,8 +114,8 @@ class Conference < ApplicationRecord if start_hour_changed? || end_hour_changed? event_schedules = program.event_schedules.select do |event_schedule| event_schedule.start_time.hour < start_hour || - event_schedule.end_time.hour > end_hour || - (event_schedule.end_time.hour == end_hour && event_schedule.end_time.minute > 0) + event_schedule.end_time.hour > end_hour || + (event_schedule.end_time.hour == end_hour && event_schedule.end_time.minute > 0) end event_schedules.each(&:destroy) end @@ -151,7 +153,7 @@ class Conference < ApplicationRecord def get_submissions_per_week result = [] - if program && program.cfp && program.events + if program&.cfp && program.events submissions = program.events.select(:week).group(:week).order(:week).count start_week = program.cfp.start_week weeks = program.cfp.weeks @@ -168,7 +170,7 @@ class Conference < ApplicationRecord # * +Array+ -> e.g. 'Submitted' => [0, 3, 3, 5] -> first week 0 events, second week 3 events. def get_submissions_data result = {} - if program && program.cfp && program.events + if program&.cfp && program.events result = get_events_per_week_by_state start_week = program.cfp.start_week @@ -196,9 +198,9 @@ class Conference < ApplicationRecord result = [] if registrations && - registration_period && - registration_period.start_date && - registration_period.end_date + registration_period && + registration_period.start_date && + registration_period.end_date reg = registrations.group(:week).order(:week).count start_week = get_registration_start_week @@ -269,11 +271,10 @@ class Conference < ApplicationRecord def registration_weeks result = 0 weeks = 0 - if registration_period && - registration_period.start_date && - registration_period.end_date + if registration_period&.start_date && + registration_period.end_date weeks = Date.new(registration_period.start_date.year, 12, 31) - .strftime('%W').to_i + .strftime('%W').to_i result = get_registration_end_week - get_registration_start_week + 1 end @@ -343,7 +344,7 @@ class Conference < ApplicationRecord tracks: tracks_set?, event_types: event_types_set?, difficulty_levels: difficulty_levels_set?, - splashpage: splashpage && splashpage.public? + splashpage: splashpage&.public? } result.update( @@ -370,8 +371,8 @@ class Conference < ApplicationRecord # * +hash+ -> user: submissions def get_top_submitter(limit = 5) submitter = EventUser.joins(:event).select(:user_id) - .where('event_role = ? and program_id = ?', 'submitter', Conference.find(id).program.id) - .limit(limit).group(:user_id) + .where('event_role = ? and program_id = ?', 'submitter', Conference.find(id).program.id) + .limit(limit).group(:user_id) counter = submitter.order('count_all desc').count(:all) Conference.calculate_user_submission_hash(submitter, counter) end @@ -595,12 +596,12 @@ class Conference < ApplicationRecord # * +ActiveRecord+ def self.get_active_conferences_for_dashboard result = Conference.where('start_date > ?', Time.now) - .select('id, short_title, color, start_date, organization_id') + .select('id, short_title, color, start_date, organization_id') if result.empty? result = Conference - .select('id, short_title, color, start_date, organization_id').limit(2) - .order(start_date: :desc) + .select('id, short_title, color, start_date, organization_id').limit(2) + .order(start_date: :desc) end result end @@ -671,9 +672,7 @@ class Conference < ApplicationRecord result[state.name] = count end - unless conference.events_per_week - conference.events_per_week = {} - end + conference.events_per_week = {} unless conference.events_per_week # Write to database conference.events_per_week[week] = result @@ -785,7 +784,7 @@ class Conference < ApplicationRecord # the color. We make use of big prime numbers to avoid repetition and to make # consecutive colors clearly different. def next_color_component(component, i) - big_prime_numbers = {r: 113, g: 67, b: 151} + big_prime_numbers = { r: 113, g: 67, b: 151 } ((i * big_prime_numbers[component]) % 239 + 16).to_s(16) end @@ -861,12 +860,9 @@ class Conference < ApplicationRecord # Completed weeks events_per_week.each do |week, values| values.each do |state, value| - if %i(confirmed unconfirmed).include?(state) - unless result[state.to_s.capitalize] - result[state.to_s.capitalize] = {} - end - result[state.to_s.capitalize][week.strftime('%W').to_i] = value - end + next unless %i[confirmed unconfirmed].include?(state) + result[state.to_s.capitalize] = {} unless result[state.to_s.capitalize] + result[state.to_s.capitalize][week.strftime('%W').to_i] = value end end @@ -923,9 +919,7 @@ class Conference < ApplicationRecord # * +Array+ def pad_left(first_week, start_week) left = [] - if first_week > start_week - left = Array.new(first_week - start_week - 1, 0) - end + left = Array.new(first_week - start_week - 1, 0) if first_week > start_week left end @@ -938,9 +932,7 @@ class Conference < ApplicationRecord def assert_keys_are_continuously(hash) keys = hash.keys (keys.min..keys.max).each do |key| - unless hash[key] - hash[key] = 0 - end + hash[key] = 0 unless hash[key] end Hash[hash.sort] end @@ -1048,12 +1040,11 @@ class Conference < ApplicationRecord grouped.each do |event| object = event.send(symbol) - if object - result[object.title] = { - 'value' => counter[object.id], - 'color' => object.color - } - end + next unless object + result[object.title] = { + 'value' => counter[object.id], + 'color' => object.color + } end result end @@ -1067,12 +1058,11 @@ class Conference < ApplicationRecord def calculate_track_distribution_hash(tracks_grouped, tracks_counter) result = {} tracks_grouped.each do |event| - if event.track - result[event.track.name] = { - 'value' => tracks_counter[event.track_id], - 'color' => event.track.color - } - end + next unless event.track + result[event.track.name] = { + 'value' => tracks_counter[event.track_id], + 'color' => event.track.color + } end result end @@ -1127,10 +1117,10 @@ class Conference < ApplicationRecord result = {} states.each do |key, value| result[key.capitalize] = - { - 'value' => value, - 'color' => Event.get_state_color(key) - } + { + 'value' => value, + 'color' => Event.get_state_color(key) + } end result end @@ -1145,9 +1135,7 @@ class Conference < ApplicationRecord counter.each do |key, value| # make PG happy by including the user_id in ORDER submitter = submitters.where(user_id: key).order(:user_id).first - if submitter - result[submitter.user] = value - end + result[submitter.user] = value if submitter end result end @@ -1165,9 +1153,9 @@ class Conference < ApplicationRecord # def generate_guid guid = SecureRandom.urlsafe_base64 -# begin -# guid = SecureRandom.urlsafe_base64 -# end while User.where(:guid => guid).exists? + # begin + # guid = SecureRandom.urlsafe_base64 + # end while User.where(:guid => guid).exists? self.guid = guid end @@ -1175,19 +1163,17 @@ class Conference < ApplicationRecord # Adds a random color to the conference # def add_color - unless color - self.color = get_color - end + self.color = get_color unless color end def get_color - %w( - #000000 #0000FF #00FF00 #FF0000 #FFFF00 #9900CC - #CC0066 #00FFFF #FF00FF #C0C0C0 #00008B #FFD700 - #FFA500 #FF1493 #FF00FF #F0FFFF #EE82EE #D2691E - #C0C0C0 #A52A2A #9ACD32 #9400D3 #8B008B #8B0000 - #87CEEB #808080 #800080 #008B8B #006400 - ).sample + %w[ + #000000 #0000FF #00FF00 #FF0000 #FFFF00 #9900CC + #CC0066 #00FFFF #FF00FF #C0C0C0 #00008B #FFD700 + #FFA500 #FF1493 #FF00FF #F0FFFF #EE82EE #D2691E + #C0C0C0 #A52A2A #9ACD32 #9400D3 #8B008B #8B0000 + #87CEEB #808080 #800080 #008B8B #006400 + ].sample end # Calculates items per week from a hash. @@ -1206,9 +1192,7 @@ class Conference < ApplicationRecord items.each do |key, value| # Padding - if last_key < (key.to_i - 1) - result += Array.new(key.to_i - last_key - 1, sum) - end + result += Array.new(key.to_i - last_key - 1, sum) if last_key < (key.to_i - 1) sum += value result.push(sum) @@ -1216,9 +1200,7 @@ class Conference < ApplicationRecord end # Padding right - if result.length < weeks - result += Array.new(weeks - result.length, sum) - end + result += Array.new(weeks - result.length, sum) if result.length < weeks result end diff --git a/app/models/contact.rb b/app/models/contact.rb index dd7196dd..f7db79e2 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Contact < ApplicationRecord has_paper_trail on: [:update], ignore: [:updated_at], meta: { conference_id: :conference_id } @@ -6,7 +8,7 @@ class Contact < ApplicationRecord validates :conference, presence: true # Conferences only have one contact validates :facebook, :twitter, :googleplus, :instagram, :mastodon, - format: URI::regexp(%w(http https)), allow_blank: true + format: URI.regexp(%w[http https]), allow_blank: true def has_social_media? return true if facebook.present? || twitter.present? || googleplus.present? || instagram.present? || mastodon.present? || email.present? diff --git a/app/models/difficulty_level.rb b/app/models/difficulty_level.rb index d9a09e22..98186693 100644 --- a/app/models/difficulty_level.rb +++ b/app/models/difficulty_level.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DifficultyLevel < ApplicationRecord belongs_to :program, touch: true has_many :events, dependent: :nullify diff --git a/app/models/email_settings.rb b/app/models/email_settings.rb index 2c593b96..b8b682bb 100644 --- a/app/models/email_settings.rb +++ b/app/models/email_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class EmailSettings < ApplicationRecord belongs_to :conference @@ -11,12 +13,15 @@ class EmailSettings < ApplicationRecord 'conference_start_date' => conference.start_date, 'conference_end_date' => conference.end_date, 'registrationlink' => Rails.application.routes.url_helpers.conference_conference_registration_url( - conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')), + conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000') + ), 'conference_splash_link' => Rails.application.routes.url_helpers.conference_url( - conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')), + conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000') + ), 'schedule_link' => Rails.application.routes.url_helpers.conference_schedule_url( - conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')) + conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000') + ) } if conference.program.cfp @@ -43,12 +48,11 @@ class EmailSettings < ApplicationRecord if event h['eventtitle'] = event.title h['proposalslink'] = Rails.application.routes.url_helpers.conference_program_proposals_url( - conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')) + conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000') + ) end - if booth - h['booth_title'] = booth.title - end + h['booth_title'] = booth.title if booth h end @@ -71,8 +75,8 @@ class EmailSettings < ApplicationRecord def parse_template(text, values) values.each do |key, value| - if value.kind_of?(Date) - text = text.gsub "{#{key}}", value.strftime('%Y-%m-%d') unless text.blank? + if value.is_a?(Date) + text = text.gsub "{#{key}}", value.strftime('%Y-%m-%d') if text.present? else text = text.gsub "{#{key}}", value unless text.blank? || value.blank? end diff --git a/app/models/event.rb b/app/models/event.rb index 943572eb..9d7d80aa 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + class Event < ApplicationRecord include ActiveRecord::Transitions include RevisionCount - has_paper_trail on: [:create, :update], ignore: [:updated_at, :guid, :week], meta: { conference_id: :conference_id } + has_paper_trail on: %i[create update], ignore: %i[updated_at guid week], meta: { conference_id: :conference_id } acts_as_commentable @@ -61,10 +63,10 @@ class Event < ApplicationRecord state :rejected event :restart do - transitions to: :new, from: [:rejected, :withdrawn, :canceled] + transitions to: :new, from: %i[rejected withdrawn canceled] end event :withdraw do - transitions to: :withdrawn, from: [:new, :unconfirmed, :confirmed] + transitions to: :withdrawn, from: %i[new unconfirmed confirmed] end event :accept do transitions to: :unconfirmed, from: [:new], on_transition: :process_acceptance @@ -73,7 +75,7 @@ class Event < ApplicationRecord transitions to: :confirmed, from: :unconfirmed, on_transition: :process_confirmation end event :cancel do - transitions to: :canceled, from: [:unconfirmed, :confirmed] + transitions to: :canceled, from: %i[unconfirmed confirmed] end event :reject do transitions to: :rejected, from: [:new], on_transition: :process_rejection @@ -108,7 +110,7 @@ class Event < ApplicationRecord # ====Returns # * +true+ -> If the event has votes (optionally, by the user) # * +false+ -> If the event does not have any votes (optionally, by the user) - def voted?(user=nil) + def voted?(user = nil) return votes.where(user: user).any? if user votes.any? @@ -128,9 +130,7 @@ class Event < ApplicationRecord def speakers_ordered speakers_list = speakers.to_a - if speakers_list.reject! { |speaker| speaker == submitter } - speakers_list.unshift(submitter) - end + speakers_list.unshift(submitter) if speakers_list.reject! { |speaker| speaker == submitter } speakers_list end @@ -141,28 +141,26 @@ class Event < ApplicationRecord def process_confirmation if program.conference.email_settings.send_on_confirmed_without_registration? && - program.conference.email_settings.confirmed_without_registration_body && - program.conference.email_settings.confirmed_without_registration_subject - if program.conference.registrations.where(user_id: submitter.id).first.nil? - Mailbot.confirm_reminder_mail(self).deliver_later - end + program.conference.email_settings.confirmed_without_registration_body && + program.conference.email_settings.confirmed_without_registration_subject + Mailbot.confirm_reminder_mail(self).deliver_later if program.conference.registrations.where(user_id: submitter.id).first.nil? end end def process_acceptance(options) if program.conference.email_settings.send_on_accepted && - program.conference.email_settings.accepted_body && - program.conference.email_settings.accepted_subject && - !options[:send_mail].blank? + program.conference.email_settings.accepted_body && + program.conference.email_settings.accepted_subject && + options[:send_mail].present? Mailbot.acceptance_mail(self).deliver_later end end def process_rejection(options) if program.conference.email_settings.send_on_rejected && - program.conference.email_settings.rejected_body && - program.conference.email_settings.rejected_subject && - !options[:send_mail].blank? + program.conference.email_settings.rejected_body && + program.conference.email_settings.rejected_subject && + options[:send_mail].present? Mailbot.rejection_mail(self).deliver_later end end @@ -186,28 +184,26 @@ class Event < ApplicationRecord def update_state(transition, mail = false, subject = false, send_mail = false, send_mail_param) alert = '' - if mail && send_mail_param && subject && send_mail - alert = 'Update Email Subject before Sending Mails' - end - begin - if mail - send(transition, - send_mail: send_mail_param) - else - send(transition) - end - save - # If the event was previously scheduled, and then withdrawn or cancelled - # its event_schedule will have enabled set to false - # If the event is now confirmed again, we want it to be available for scheduling - Rails.logger.debug "transition is #{transition}" - if transition == :confirm - Rails.logger.debug "schedules #{EventSchedule.unscoped.where(event: self, enabled: false)}" - EventSchedule.unscoped.where(event: self, enabled: false).destroy_all - end - rescue Transitions::InvalidTransition => e - alert = "Update state failed. #{e.message}" + alert = 'Update Email Subject before Sending Mails' if mail && send_mail_param && subject && send_mail + begin + if mail + send(transition, + send_mail: send_mail_param) + else + send(transition) end + save + # If the event was previously scheduled, and then withdrawn or cancelled + # its event_schedule will have enabled set to false + # If the event is now confirmed again, we want it to be available for scheduling + Rails.logger.debug "transition is #{transition}" + if transition == :confirm + Rails.logger.debug "schedules #{EventSchedule.unscoped.where(event: self, enabled: false)}" + EventSchedule.unscoped.where(event: self, enabled: false).destroy_all + end + rescue Transitions::InvalidTransition => e + alert = "Update state failed. #{e.message}" + end alert end @@ -227,10 +223,10 @@ class Event < ApplicationRecord { registered: speakers.all? { |speaker| program.conference.user_registered? speaker }, commercials: commercials.any?, - biographies: speakers.all? { |speaker| !speaker.biography.blank? }, - subtitle: !subtitle.blank?, - track: (!track.blank? unless program.tracks.empty?), - difficulty_level: !difficulty_level.blank?, + biographies: speakers.all? { |speaker| speaker.biography.present? }, + subtitle: subtitle.present?, + track: (track.present? unless program.tracks.empty?), + difficulty_level: difficulty_level.present?, title: true, abstract: true }.with_indifferent_access @@ -266,9 +262,7 @@ class Event < ApplicationRecord event_schedules.find_by(schedule_id: selected_schedule_id).try(:start_time) end - def conference - program.conference - end + delegate :conference, to: :program private @@ -309,9 +303,11 @@ class Event < ApplicationRecord 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 && - (Date.today > program.conference.end_date) + if program.conference&.end_date && + (Date.today > program.conference.end_date) + errors + .add(:created_at, "can't be after the conference end date!") + end end def conference_id @@ -322,7 +318,7 @@ class Event < ApplicationRecord # Allow only confirmed tracks that belong to the same program as the event # def valid_track - return unless track && track.program && program + return unless track&.program && program errors.add(:track, 'is invalid') unless track.confirmed? && track.program == program end diff --git a/app/models/event_schedule.rb b/app/models/event_schedule.rb index 9d59713d..f4d26c17 100644 --- a/app/models/event_schedule.rb +++ b/app/models/event_schedule.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class EventSchedule < ApplicationRecord default_scope { where(enabled: true) } belongs_to :schedule @@ -71,13 +73,9 @@ class EventSchedule < ApplicationRecord def during_track return unless event.try(:track) && start_time - if event.track.try(:start_date) && event.track.start_date > start_time - errors.add(:start_time, "can't be before the track's start date (#{event.track.start_date})") - end + errors.add(:start_time, "can't be before the track's start date (#{event.track.start_date})") if event.track.try(:start_date) && event.track.start_date > start_time - if event.track.try(:end_date) && event.track.end_date + 1.day < end_time - errors.add(:end_time, "can't be after the track's end date (#{event.track.end_date})") - end + errors.add(:end_time, "can't be after the track's end date (#{event.track.end_date})") if event.track.try(:end_date) && event.track.end_date + 1.day < end_time end ## diff --git a/app/models/event_type.rb b/app/models/event_type.rb index 4b19621b..7de162ed 100644 --- a/app/models/event_type.rb +++ b/app/models/event_type.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class EventType < ApplicationRecord belongs_to :program, touch: true has_many :events, dependent: :restrict_with_error @@ -6,7 +8,7 @@ class EventType < ApplicationRecord ignore: %i[updated_at] validates :title, presence: true - validates :length, numericality: {greater_than: 0} + validates :length, numericality: { greater_than: 0 } validates :minimum_abstract_length, presence: true validates :maximum_abstract_length, presence: true validate :length_step diff --git a/app/models/event_user.rb b/app/models/event_user.rb index 85e5f8d8..fd1baa2d 100644 --- a/app/models/event_user.rb +++ b/app/models/event_user.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + class EventUser < ApplicationRecord # TODO: Do we need these roles? - ROLES = [%w[Speaker speaker], %w[Submitter submitter], %w[Moderator moderator]] + ROLES = [%w[Speaker speaker], %w[Submitter submitter], %w[Moderator moderator]].freeze belongs_to :event, touch: true belongs_to :user diff --git a/app/models/events_registration.rb b/app/models/events_registration.rb index 6539064e..735df2a7 100644 --- a/app/models/events_registration.rb +++ b/app/models/events_registration.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class EventsRegistration < ApplicationRecord belongs_to :registration belongs_to :event diff --git a/app/models/lodging.rb b/app/models/lodging.rb index 50feaf41..2f7a87ad 100644 --- a/app/models/lodging.rb +++ b/app/models/lodging.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Lodging < ApplicationRecord belongs_to :conference diff --git a/app/models/openid.rb b/app/models/openid.rb index b0f45f0c..feaa6a9d 100644 --- a/app/models/openid.rb +++ b/app/models/openid.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Openid < ApplicationRecord belongs_to :user validates :provider, :uid, :email, presence: true diff --git a/app/models/organization.rb b/app/models/organization.rb index 1e3974de..96a17bfa 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Organization < ApplicationRecord resourcify :roles, dependent: :delete_all diff --git a/app/models/payment.rb b/app/models/payment.rb index 3938dcb6..a7e9e22a 100644 --- a/app/models/payment.rb +++ b/app/models/payment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Payment < ApplicationRecord has_many :ticket_purchases belongs_to :user @@ -32,7 +34,6 @@ class Payment < ApplicationRecord self.authorization_code = gateway_response[:id] self.status = 'success' true - rescue Stripe::StripeError => error errors.add(:base, error.message) self.status = 'failure' diff --git a/app/models/physical_ticket.rb b/app/models/physical_ticket.rb index e98646b0..2493cbbe 100644 --- a/app/models/physical_ticket.rb +++ b/app/models/physical_ticket.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PhysicalTicket < ApplicationRecord belongs_to :ticket_purchase has_one :ticket, through: :ticket_purchase diff --git a/app/models/program.rb b/app/models/program.rb index 14554786..5d6fe426 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # cannot delete program if there are events submitted class Program < ApplicationRecord @@ -42,7 +44,7 @@ class Program < ApplicationRecord has_many :event_schedules, through: :events has_many :event_users, through: :events - has_many :program_events_speakers, -> {where(event_role: 'speaker')}, through: :events, source: :event_users + has_many :program_events_speakers, -> { where(event_role: 'speaker') }, through: :events, source: :event_users has_many :speakers, -> { distinct }, through: :program_events_speakers, source: :user do def confirmed joins(:events).where(events: { state: :confirmed }) @@ -61,7 +63,7 @@ class Program < ApplicationRecord accepts_nested_attributes_for :tracks, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true accepts_nested_attributes_for :difficulty_levels, allow_destroy: true -# validates :conference_id, presence: true, uniqueness: true + # validates :conference_id, presence: true, uniqueness: true validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10, only_integer: true } validates :schedule_interval, numericality: { greater_than_or_equal_to: 5, less_than_or_equal_to: 60 }, presence: true validate :schedule_interval_divisor_60 @@ -80,7 +82,7 @@ class Program < ApplicationRecord tracks.self_organized.confirmed.order(start_date: :asc).each do |track| event_schedules += track.selected_schedule.event_schedules.order(start_time: :asc) if track.selected_schedule end - event_schedules.sort_by(&:start_time) if event_schedules + event_schedules&.sort_by(&:start_time) end ## @@ -154,11 +156,11 @@ class Program < ApplicationRecord # do not notify if the schedule is not public return false unless schedule_public # do not notify unless the mail content is set up - (!conference.email_settings.program_schedule_public_subject.blank? && !conference.email_settings.program_schedule_public_body.blank?) + (conference.email_settings.program_schedule_public_subject.present? && conference.email_settings.program_schedule_public_body.present?) end def languages_list - languages.split(',').map {|l| ISO_639.find(l).english_name} if languages.present? + languages.split(',').map { |l| ISO_639.find(l).english_name } if languages.present? end ## @@ -224,16 +226,16 @@ class Program < ApplicationRecord # Check if languages string has the right format. Used as validation. # def check_languages_format - return unless languages.present? + return if languages.blank? # All white spaces are removed to allow languages to be separated by ',' and ', '. The languages string without spaces is saved self.languages = languages.delete(' ').downcase - errors.add(:languages, 'must be two letters separated by commas') && return unless - languages.match(/^$|(\A[a-z][a-z](,[a-z][a-z])*\z)/).present? + errors.add(:languages, 'must be two letters separated by commas') && return if + languages.match(/^$|(\A[a-z][a-z](,[a-z][a-z])*\z)/).blank? languages_array = languages.split(',') # We check that languages are not repeated errors.add(:languages, "can't be repeated") && return unless languages_array.uniq!.nil? # We check if every language is a valid ISO 639-1 language - errors.add(:languages, 'must be ISO 639-1 valid codes') unless languages_array.select{ |x| ISO_639.find(x).nil? }.empty? + errors.add(:languages, 'must be ISO 639-1 valid codes') unless languages_array.select { |x| ISO_639.find(x).nil? }.empty? end ## @@ -259,7 +261,7 @@ class Program < ApplicationRecord def normalize_event_types_length event_types.each do |event_type| new_length = event_type.length > schedule_interval ? event_type.length - (event_type.length % schedule_interval) : schedule_interval - event_type.update_attributes length: new_length + event_type.update length: new_length end end end diff --git a/app/models/qanswer.rb b/app/models/qanswer.rb index 2e581131..535da321 100644 --- a/app/models/qanswer.rb +++ b/app/models/qanswer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Qanswer < ApplicationRecord belongs_to :question belongs_to :answer, dependent: :delete diff --git a/app/models/question.rb b/app/models/question.rb index 0c7456a9..702a3784 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Question < ApplicationRecord belongs_to :question_type has_and_belongs_to_many :conferences diff --git a/app/models/question_type.rb b/app/models/question_type.rb index 84fd1a80..2a5ebc24 100644 --- a/app/models/question_type.rb +++ b/app/models/question_type.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class QuestionType < ApplicationRecord has_many :questions end diff --git a/app/models/registration.rb b/app/models/registration.rb index 45d2d55b..1bd6af0b 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Registration < ApplicationRecord require 'csv' belongs_to :user @@ -9,7 +11,7 @@ class Registration < ApplicationRecord has_many :events_registrations has_many :events, through: :events_registrations, dependent: :destroy - has_paper_trail ignore: %i(updated_at week), meta: { conference_id: :conference_id } + has_paper_trail ignore: %i[updated_at week], meta: { conference_id: :conference_id } accepts_nested_attributes_for :user accepts_nested_attributes_for :qanswers @@ -64,9 +66,7 @@ class Registration < ApplicationRecord end def send_registration_mail - if conference.email_settings.send_on_registration? - Mailbot.registration_mail(conference, user).deliver_later - end + Mailbot.registration_mail(conference, user).deliver_later if conference.email_settings.send_on_registration? end def set_week @@ -77,8 +77,6 @@ class Registration < ApplicationRecord end def registration_limit_not_exceed - if conference.registration_limit > 0 && conference.registrations(:reload).count >= conference.registration_limit - errors.add(:base, 'Registration limit exceeded') - end + errors.add(:base, 'Registration limit exceeded') if conference.registration_limit > 0 && conference.registrations(:reload).count >= conference.registration_limit end end diff --git a/app/models/registration_period.rb b/app/models/registration_period.rb index 9aa82444..d5335591 100644 --- a/app/models/registration_period.rb +++ b/app/models/registration_period.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RegistrationPeriod < ApplicationRecord belongs_to :conference @@ -10,15 +12,21 @@ class RegistrationPeriod < ApplicationRecord 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) + if 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})") + end - 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) + if 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})") + end 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 + if start_date && end_date && start_date > end_date + errors + .add(:start_date, "can't be after the end date") + end end end diff --git a/app/models/resource.rb b/app/models/resource.rb index 77363cfb..991ce0cf 100644 --- a/app/models/resource.rb +++ b/app/models/resource.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Resource < ApplicationRecord belongs_to :conference validates :name, :used, :quantity, presence: true diff --git a/app/models/role.rb b/app/models/role.rb index fcbac932..dd3ff2a6 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + class Role < ApplicationRecord belongs_to :resource, polymorphic: true has_many :users_roles has_many :users, through: :users_roles - has_paper_trail on: [:create, :update], only: [:name, :description], meta: { conference_id: :resource_id } + has_paper_trail on: %i[create update], only: %i[name description], meta: { conference_id: :resource_id } before_destroy :cancel scopify diff --git a/app/models/room.rb b/app/models/room.rb index 718704de..e80887c8 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Room < ApplicationRecord include RevisionCount belongs_to :venue @@ -12,9 +14,7 @@ class Room < ApplicationRecord validates :size, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true - def conference - venue.conference - end + delegate :conference, to: :venue private diff --git a/app/models/schedule.rb b/app/models/schedule.rb index 3bd1f1fa..1584733f 100644 --- a/app/models/schedule.rb +++ b/app/models/schedule.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Schedule < ApplicationRecord belongs_to :program belongs_to :track diff --git a/app/models/splashpage.rb b/app/models/splashpage.rb index 388831ba..5cd9ef0d 100644 --- a/app/models/splashpage.rb +++ b/app/models/splashpage.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Splashpage < ApplicationRecord belongs_to :conference diff --git a/app/models/sponsor.rb b/app/models/sponsor.rb index d54d95c7..fa63411f 100644 --- a/app/models/sponsor.rb +++ b/app/models/sponsor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Sponsor < ApplicationRecord belongs_to :sponsorship_level belongs_to :conference diff --git a/app/models/sponsorship_level.rb b/app/models/sponsorship_level.rb index f742e41b..48f41594 100644 --- a/app/models/sponsorship_level.rb +++ b/app/models/sponsorship_level.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SponsorshipLevel < ApplicationRecord validates :title, presence: true belongs_to :conference diff --git a/app/models/subscription.rb b/app/models/subscription.rb index 9d78975a..3d341bc7 100644 --- a/app/models/subscription.rb +++ b/app/models/subscription.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + class Subscription < ApplicationRecord belongs_to :conference belongs_to :user - has_paper_trail on: %i(create destroy), ignore: [:updated_at], meta: { conference_id: :conference_id } + has_paper_trail on: %i[create destroy], ignore: [:updated_at], meta: { conference_id: :conference_id } validates :user_id, uniqueness: { scope: :conference_id, message: 'already subscribed!' } end diff --git a/app/models/target.rb b/app/models/target.rb index 55365a6a..424d075f 100644 --- a/app/models/target.rb +++ b/app/models/target.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Target < ApplicationRecord include ActionView::Helpers::TextHelper diff --git a/app/models/ticket.rb b/app/models/ticket.rb index fa053e0d..a57c90cc 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Ticket < ApplicationRecord belongs_to :conference has_many :ticket_purchases, dependent: :destroy @@ -58,7 +60,7 @@ class Ticket < ApplicationRecord def self.total_price_user(conference, user, paid: false) tickets = TicketPurchase.where(conference: conference, user: user, paid: paid) - tickets.inject(0){ |sum, ticket| sum + (ticket.amount_paid * ticket.quantity) } + tickets.inject(0) { |sum, ticket| sum + (ticket.amount_paid * ticket.quantity) } end def tickets_turnover_total(id) @@ -77,8 +79,6 @@ class Ticket < ApplicationRecord def tickets_of_conference_have_same_currency tickets = Ticket.where(conference_id: conference_id) return if tickets.count.zero? || (tickets.count == 1 && self == tickets.first) - unless tickets.all?{|t| t.price_currency == price_currency } - errors.add(:price_currency, 'is different from the existing tickets of this conference.') - end + errors.add(:price_currency, 'is different from the existing tickets of this conference.') unless tickets.all? { |t| t.price_currency == price_currency } end end diff --git a/app/models/ticket_purchase.rb b/app/models/ticket_purchase.rb index 35f36b4c..752dbf2b 100644 --- a/app/models/ticket_purchase.rb +++ b/app/models/ticket_purchase.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TicketPurchase < ApplicationRecord belongs_to :ticket belongs_to :user @@ -38,9 +40,7 @@ class TicketPurchase < ApplicationRecord else purchase_ticket(conference, quantity, ticket, user) end - if purchase && !purchase.save - errors.push(purchase.errors.full_messages) - end + errors.push(purchase.errors.full_messages) if purchase && !purchase.save end end end @@ -75,7 +75,7 @@ class TicketPurchase < ApplicationRecord end def pay(payment) - update_attributes(paid: true, payment: payment) + update(paid: true, payment: payment) PhysicalTicket.transaction do quantity.times { physical_tickets.create } end @@ -83,15 +83,11 @@ class TicketPurchase < ApplicationRecord end def one_registration_ticket_per_user - if ticket.try(:registration_ticket?) && quantity != 1 - errors.add(:quantity, 'cannot be greater than one for registration tickets.') - end + errors.add(:quantity, 'cannot be greater than one for registration tickets.') if ticket.try(:registration_ticket?) && quantity != 1 end def registration_ticket_already_purchased - if ticket.try(:registration_ticket?) && user.tickets.for_registration(conference).present? - errors.add(:quantity, 'cannot be greater than one for registration tickets.') - end + errors.add(:quantity, 'cannot be greater than one for registration tickets.') if ticket.try(:registration_ticket?) && user.tickets.for_registration(conference).present? end end diff --git a/app/models/ticket_scanning.rb b/app/models/ticket_scanning.rb index 27536c86..70b9af2f 100644 --- a/app/models/ticket_scanning.rb +++ b/app/models/ticket_scanning.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TicketScanning < ApplicationRecord belongs_to :physical_ticket @@ -6,8 +8,6 @@ class TicketScanning < ApplicationRecord private def mark_user_present - if physical_ticket.ticket.registration_ticket? - physical_ticket.user.mark_attendance_for_conference(physical_ticket.conference) - end + physical_ticket.user.mark_attendance_for_conference(physical_ticket.conference) if physical_ticket.ticket.registration_ticket? end end diff --git a/app/models/track.rb b/app/models/track.rb index 21f6eaa1..36cfdab2 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Track < ApplicationRecord include ActiveRecord::Transitions include RevisionCount @@ -24,7 +26,7 @@ class Track < ApplicationRecord } validates :state, presence: true, - inclusion: { in: %w(new to_accept accepted confirmed to_reject rejected canceled withdrawn) } + inclusion: { in: %w[new to_accept accepted confirmed to_reject rejected canceled withdrawn] } validates :cfp_active, inclusion: { in: [true, false] } validates :start_date, presence: true, if: :self_organized_and_accepted_or_confirmed? validates :end_date, presence: true, if: :self_organized_and_accepted_or_confirmed? @@ -54,34 +56,32 @@ class Track < ApplicationRecord state :withdrawn event :restart do - transitions to: :new, from: [:rejected, :withdrawn, :canceled] + transitions to: :new, from: %i[rejected withdrawn canceled] end event :to_accept do - transitions to: :to_accept, from: [:new, :to_reject] + transitions to: :to_accept, from: %i[new to_reject] end event :accept do - transitions to: :accepted, from: [:new, :to_accept], on_transition: :create_organizer_role + transitions to: :accepted, from: %i[new to_accept], on_transition: :create_organizer_role end event :confirm do transitions to: :confirmed, from: [:accepted], on_transition: :assign_role_to_submitter end event :to_reject do - transitions to: :to_reject, from: [:new, :to_accept] + transitions to: :to_reject, from: %i[new to_accept] end event :reject do - transitions to: :rejected, from: [:new, :to_reject] + transitions to: :rejected, from: %i[new to_reject] end event :cancel do - transitions to: :canceled, from: [:to_accept, :to_reject, :accepted, :confirmed], on_transition: :revoke_role_and_cleanup + transitions to: :canceled, from: %i[to_accept to_reject accepted confirmed], on_transition: :revoke_role_and_cleanup end event :withdraw do - transitions to: :withdrawn, from: [:new, :to_accept, :to_reject, :accepted, :confirmed], on_transition: :revoke_role_and_cleanup + transitions to: :withdrawn, from: %i[new to_accept to_reject accepted confirmed], on_transition: :revoke_role_and_cleanup end end - def conference - program.conference - end + delegate :conference, to: :program ## # Checks if the track is self-organized @@ -113,10 +113,8 @@ class Track < ApplicationRecord def revoke_role_and_cleanup role = Role.find_by(name: 'track_organizer', resource: self) - if role - role.users.each do |user| - user.remove_role 'track_organizer', self - end + role&.users&.each do |user| + user.remove_role 'track_organizer', self end self.selected_schedule_id = nil @@ -175,9 +173,9 @@ class Track < ApplicationRecord def generate_guid guid = SecureRandom.urlsafe_base64 -# begin -# guid = SecureRandom.urlsafe_base64 -# end while Person.where(:guid => guid).exists? + # begin + # guid = SecureRandom.urlsafe_base64 + # end while Person.where(:guid => guid).exists? self.guid = guid end @@ -227,12 +225,11 @@ class Track < ApplicationRecord return unless start_date && end_date && room && program.try(:tracks) (program.tracks.accepted + program.tracks.confirmed - [self]).each do |existing_track| next unless existing_track.room == room && existing_track.start_date && existing_track.end_date - if start_date >= existing_track.start_date && start_date <= existing_track.end_date || - end_date >= existing_track.start_date && end_date <= existing_track.end_date || - start_date <= existing_track.start_date && end_date >= existing_track.end_date - errors.add(:track, 'has overlapping dates with a confirmed or accepted track in the same room') - break - end + next unless start_date >= existing_track.start_date && start_date <= existing_track.end_date || + end_date >= existing_track.start_date && end_date <= existing_track.end_date || + start_date <= existing_track.start_date && end_date >= existing_track.end_date + errors.add(:track, 'has overlapping dates with a confirmed or accepted track in the same room') + break end end end diff --git a/app/models/user.rb b/app/models/user.rb index cb09e78c..cdd3e241 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class IChainRecordNotFound < StandardError end @@ -17,8 +19,8 @@ class User < ApplicationRecord has_many :users_roles has_many :roles, through: :users_roles, dependent: :destroy - has_paper_trail on: [:create, :update], ignore: [:sign_in_count, :remember_created_at, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip, :last_sign_in_ip, :unconfirmed_email, - :avatar_content_type, :avatar_file_size, :avatar_updated_at, :updated_at, :confirmation_sent_at, :confirmation_token, :reset_password_token] + has_paper_trail on: %i[create update], ignore: %i[sign_in_countremember_created_atcurrent_sign_in_atlast_sign_in_atcurrent_sign_in_iplast_sign_in_ipunconfirmed_email + avatar_content_type avatar_file_size avatar_updated_at updated_at confirmation_sent_at confirmation_token reset_password_token] include Gravtastic gravtastic size: 32 @@ -28,7 +30,7 @@ class User < ApplicationRecord after_save :touch_events # add scope - scope :comment_notifiable, ->(conference) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', conference.id)} + scope :comment_notifiable, ->(conference) { joins(:roles).where('roles.name IN (?)', %i[organizer cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', conference.id) } # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, @@ -40,7 +42,7 @@ class User < ApplicationRecord else [:database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, - :omniauthable, omniauth_providers: [:suse, :google, :facebook, :github]] + :omniauthable, omniauth_providers: %i[suse google facebook github]] end devise(*devise_modules) @@ -51,9 +53,9 @@ class User < ApplicationRecord has_many :event_users, dependent: :destroy has_many :events, -> { distinct }, through: :event_users - has_many :presented_events, -> { joins(:event_users).where(event_users: {event_role: 'speaker'}).distinct }, through: :event_users, source: :event + has_many :presented_events, -> { joins(:event_users).where(event_users: { event_role: 'speaker' }).distinct }, through: :event_users, source: :event has_many :registrations, dependent: :destroy do - def for_conference conference + def for_conference(conference) where(conference: conference).first end end @@ -61,7 +63,7 @@ class User < ApplicationRecord has_many :ticket_purchases, dependent: :destroy has_many :payments, dependent: :destroy has_many :tickets, through: :ticket_purchases, source: :ticket do - def for_registration conference + def for_registration(conference) where(conference: conference, registration_ticket: true).first end end @@ -81,7 +83,7 @@ class User < ApplicationRecord validates :username, uniqueness: { - case_sensitive: false + case_sensitive: false }, presence: true @@ -95,48 +97,48 @@ class User < ApplicationRecord # === Returns # * +true+ if the user attended the event # * +false+ if the user did not attend the event - def attended_event? event + def attended_event?(event) event_registration = event.events_registrations.find_by(registration: registrations) - return false unless event_registration.present? + return false if event_registration.blank? event_registration.attended end - def mark_attendance_for_conference conference + def mark_attendance_for_conference(conference) registration = registrations.for_conference(conference) registration.attended = true registration.save end def name - self[:name].blank? ? username : self[:name] + self[:name].presence || username end ## # Checks if a user has registered to an event # ====Returns # * +true+ or +false+ - def registered_to_event? event + def registered_to_event?(event) event.registrations.include? registrations.find_by(conference: event.program.conference) end - def subscribed? conference + def subscribed?(conference) subscriptions.find_by(conference_id: conference.id).present? end - def supports? conference + def supports?(conference) ticket_purchases.find_by(conference_id: conference.id).present? end def self.for_ichain_username(username, attributes) user = find_by(username: username) - raise UserDisabled if user && user.is_disabled + raise UserDisabled if user&.is_disabled if user - user.update_attributes(email: attributes[:email], - last_sign_in_at: user.current_sign_in_at, - current_sign_in_at: Time.current) + user.update(email: attributes[:email], + last_sign_in_at: user.current_sign_in_at, + current_sign_in_at: Time.current) else begin user = create!(username: username, email: attributes[:email]) @@ -163,9 +165,7 @@ class User < ApplicationRecord def self.find_for_auth(auth, current_user = nil) user = current_user - if user.nil? # No current user available, user is not already logged in - user = User.where(email: auth.info.email).first_or_initialize - end + user = User.where(email: auth.info.email).first_or_initialize if user.nil? # No current user available, user is not already logged in if user.new_record? user.email = auth.info.email @@ -231,9 +231,7 @@ class User < ApplicationRecord private def setup_role - if User.count == 1 && User.first.email == 'deleted@localhost.osem' - self.is_admin = true - end + self.is_admin = true if User.count == 1 && User.first.email == 'deleted@localhost.osem' end def touch_events diff --git a/app/models/users_role.rb b/app/models/users_role.rb index f233e995..6e8d86fb 100644 --- a/app/models/users_role.rb +++ b/app/models/users_role.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + class UsersRole < ApplicationRecord belongs_to :role belongs_to :user - has_paper_trail on: [:create, :destroy], meta: { conference_id: :conference_id } + has_paper_trail on: %i[create destroy], meta: { conference_id: :conference_id } private diff --git a/app/models/vchoice.rb b/app/models/vchoice.rb index b258c34d..bf5d05a6 100644 --- a/app/models/vchoice.rb +++ b/app/models/vchoice.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Vchoice < ApplicationRecord belongs_to :vday belongs_to :vposition diff --git a/app/models/vday.rb b/app/models/vday.rb index bd122291..5a9b52cf 100644 --- a/app/models/vday.rb +++ b/app/models/vday.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Vday < ApplicationRecord belongs_to :conference diff --git a/app/models/venue.rb b/app/models/venue.rb index 6a758242..7139c042 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + class Venue < ApplicationRecord belongs_to :conference has_one :commercial, as: :commercialable, dependent: :destroy has_many :rooms, dependent: :destroy before_create :generate_guid - has_paper_trail ignore: [:updated_at, :guid], meta: { conference_id: :conference_id } + has_paper_trail ignore: %i[updated_at guid], meta: { conference_id: :conference_id } accepts_nested_attributes_for :commercial, allow_destroy: true validates :name, :street, :city, :country, presence: true @@ -19,7 +21,7 @@ class Venue < ApplicationRecord def country_name name = ISO3166::Country[country] - name.name if name + name&.name end def location? @@ -37,7 +39,7 @@ class Venue < ApplicationRecord # do not notify unless the address changed return false unless name_changed? || street_changed? || city_changed? || country_changed? # do not notify unless the mail content is set up - (!conference.email_settings.venue_updated_subject.blank? && !conference.email_settings.venue_updated_body.blank?) + (conference.email_settings.venue_updated_subject.present? && conference.email_settings.venue_updated_body.present?) end # TODO: create a module to be mixed into model to perform same operation diff --git a/app/models/visit.rb b/app/models/visit.rb index 76b1981b..0afa9183 100644 --- a/app/models/visit.rb +++ b/app/models/visit.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Visit < ApplicationRecord has_many :ahoy_events, class_name: 'Ahoy::Event' belongs_to :user diff --git a/app/models/vote.rb b/app/models/vote.rb index 9e1c572f..2ce0e671 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Vote < ApplicationRecord belongs_to :user belongs_to :event diff --git a/app/models/vposition.rb b/app/models/vposition.rb index 38ef27fe..6599bc8a 100644 --- a/app/models/vposition.rb +++ b/app/models/vposition.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Vposition < ApplicationRecord belongs_to :conference diff --git a/app/pdfs/ticket_pdf.rb b/app/pdfs/ticket_pdf.rb index d21a1e27..834d12e2 100644 --- a/app/pdfs/ticket_pdf.rb +++ b/app/pdfs/ticket_pdf.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'open-uri' class TicketPdf < Prawn::Document diff --git a/app/serializers/conference_serializer.rb b/app/serializers/conference_serializer.rb index 7bb96131..fa94ad78 100644 --- a/app/serializers/conference_serializer.rb +++ b/app/serializers/conference_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ConferenceSerializer < ActiveModel::Serializer include ApplicationHelper attributes :short_title, :title, :description, :start_date, :end_date, :picture_url, @@ -5,41 +7,41 @@ class ConferenceSerializer < ActiveModel::Serializer :date_range, :revision def difficulty_levels - object.program.difficulty_levels.map do |difficulty_level| { id: difficulty_level.id, - title: difficulty_level.title, - description: difficulty_level.description - } + object.program.difficulty_levels.map do |difficulty_level| + { id: difficulty_level.id, + title: difficulty_level.title, + description: difficulty_level.description } end end def event_types - object.program.event_types.map do |event_type| { id: event_type.id, - title: event_type.title, - length: event_type.length, - description: event_type.description - } + object.program.event_types.map do |event_type| + { id: event_type.id, + title: event_type.title, + length: event_type.length, + description: event_type.description } end end def rooms if object.venue - object.venue.rooms.map do |room| { id: room.id, - size: room.size, - events: room.event_schedules.map do |event_schedule| { guid: event_schedule.event.title, - title: event_schedule.event.title, - subtitle: event_schedule.event.subtitle, - abstract: event_schedule.event.abstract, - description: event_schedule.event.description, - is_highlight: event_schedule.event.is_highlight, - require_registration: event_schedule.event.require_registration, - start_time: event_schedule.start_time, - event_type_id: event_schedule.event.event_type.id, - difficulty_level_id: event_schedule.event.difficulty_level_id, - track_id: event_schedule.event.track_id, - speaker_names: event_schedule.event.speaker_names - } - end - } + object.venue.rooms.map do |room| + { id: room.id, + size: room.size, + events: room.event_schedules.map do |event_schedule| + { guid: event_schedule.event.title, + title: event_schedule.event.title, + subtitle: event_schedule.event.subtitle, + abstract: event_schedule.event.abstract, + description: event_schedule.event.description, + is_highlight: event_schedule.event.is_highlight, + require_registration: event_schedule.event.require_registration, + start_time: event_schedule.start_time, + event_type_id: event_schedule.event.event_type.id, + difficulty_level_id: event_schedule.event.difficulty_level_id, + track_id: event_schedule.event.track_id, + speaker_names: event_schedule.event.speaker_names } + end } end else [] @@ -47,10 +49,10 @@ class ConferenceSerializer < ActiveModel::Serializer end def tracks - object.program.tracks.map do |track| { 'id' => track.id, - 'name' => track.name, - 'description' => track.description - } + object.program.tracks.map do |track| + { 'id' => track.id, + 'name' => track.name, + 'description' => track.description } end end @@ -59,8 +61,6 @@ class ConferenceSerializer < ActiveModel::Serializer end def date_range - if defined? date_string(object.start_date, object.end_date) - date_string(object.start_date, object.end_date).try(:split, ',').try(:first) - end + date_string(object.start_date, object.end_date).try(:split, ',').try(:first) if defined? date_string(object.start_date, object.end_date) end end diff --git a/app/serializers/conferences_array_serializer.rb b/app/serializers/conferences_array_serializer.rb index aacaa681..8ca8df53 100644 --- a/app/serializers/conferences_array_serializer.rb +++ b/app/serializers/conferences_array_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Needed in order to add the API version number to the conferences array # diff --git a/app/serializers/event_schedule_serializer.rb b/app/serializers/event_schedule_serializer.rb index c0de52eb..71a2ea59 100644 --- a/app/serializers/event_schedule_serializer.rb +++ b/app/serializers/event_schedule_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class EventScheduleSerializer < ActiveModel::Serializer include ActionView::Helpers::TextHelper diff --git a/app/serializers/event_serializer.rb b/app/serializers/event_serializer.rb index d58d23d2..26d53801 100644 --- a/app/serializers/event_serializer.rb +++ b/app/serializers/event_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class EventSerializer < ActiveModel::Serializer include ActionView::Helpers::TextHelper diff --git a/app/serializers/room_serializer.rb b/app/serializers/room_serializer.rb index fc9b1921..c75db316 100644 --- a/app/serializers/room_serializer.rb +++ b/app/serializers/room_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RoomSerializer < ActiveModel::Serializer attributes :guid, :name, :description diff --git a/app/serializers/speaker_serializer.rb b/app/serializers/speaker_serializer.rb index 4a455a61..ee7e6dec 100644 --- a/app/serializers/speaker_serializer.rb +++ b/app/serializers/speaker_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SpeakerSerializer < ActiveModel::Serializer include ActionView::Helpers::TextHelper diff --git a/app/serializers/track_serializer.rb b/app/serializers/track_serializer.rb index 0019a150..0eb7bebb 100644 --- a/app/serializers/track_serializer.rb +++ b/app/serializers/track_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TrackSerializer < ActiveModel::Serializer attributes :guid, :name, :color end diff --git a/app/uploaders/picture_uploader.rb b/app/uploaders/picture_uploader.rb index 41bcab7b..7fbaadf7 100644 --- a/app/uploaders/picture_uploader.rb +++ b/app/uploaders/picture_uploader.rb @@ -1,4 +1,4 @@ -# encoding: utf-8 +# frozen_string_literal: true class PictureUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick @@ -43,7 +43,7 @@ class PictureUploader < CarrierWave::Uploader::Base # Returns the id of the instance in a split path form. e.g. returns # 000/001/234 for an id of 1234. Stolen from paperclip... def id_partition - ('%09d'.freeze % model.id).scan(/\d{3}/).join('/'.freeze) + format('%09d', model.id).scan(/\d{3}/).join('/') end # Override the directory where uploaded files will be stored. @@ -84,7 +84,7 @@ class PictureUploader < CarrierWave::Uploader::Base # Add a white list of extensions which are allowed to be uploaded. # For images you might use something like this: def extension_white_list - %w(jpg jpeg gif png) + %w[jpg jpeg gif png] end def content_type_whitelist diff --git a/app/views/admin/booths/_all_booths.xlsx.axlsx b/app/views/admin/booths/_all_booths.xlsx.axlsx index bd1cc1db..81d1ce0d 100644 --- a/app/views/admin/booths/_all_booths.xlsx.axlsx +++ b/app/views/admin/booths/_all_booths.xlsx.axlsx @@ -1,6 +1,8 @@ +# frozen_string_literal: true + wb.add_worksheet(name: 'all booths') do |sheet| bold_style = wb.styles.add_style(b: true) - wrap_text = wb.styles.add_style alignment: {wrap_text: true} + wrap_text = wb.styles.add_style alignment: { wrap_text: true } row = ['Booth ID', 'Title', 'Description', @@ -21,7 +23,7 @@ wb.add_worksheet(name: 'all booths') do |sheet| row << booth.submitter_relationship row << booth.website_url row << booth.state - sheet.add_row row , style: wrap_text - sheet.column_widths 10,20,35,35,20,30,35,10 + sheet.add_row row, style: wrap_text + sheet.column_widths 10, 20, 35, 35, 20, 30, 35, 10 end end diff --git a/app/views/admin/booths/_confirmed_booths.xlsx.axlsx b/app/views/admin/booths/_confirmed_booths.xlsx.axlsx index 2dc10013..8c990f77 100644 --- a/app/views/admin/booths/_confirmed_booths.xlsx.axlsx +++ b/app/views/admin/booths/_confirmed_booths.xlsx.axlsx @@ -1,6 +1,8 @@ +# frozen_string_literal: true + wb.add_worksheet(name: 'all booths') do |sheet| bold_style = wb.styles.add_style(b: true) - wrap_text = wb.styles.add_style alignment: {wrap_text: true} + wrap_text = wb.styles.add_style alignment: { wrap_text: true } row = ['Booth ID', 'Title', 'Description', @@ -21,7 +23,7 @@ wb.add_worksheet(name: 'all booths') do |sheet| row << booth.submitter_relationship row << booth.website_url row << booth.state - sheet.add_row row , style: wrap_text - sheet.column_widths 10,20,35,35,20,30,35,10 + sheet.add_row row, style: wrap_text + sheet.column_widths 10, 20, 35, 35, 20, 30, 35, 10 end end diff --git a/app/views/admin/booths/booths.xlsx.axlsx b/app/views/admin/booths/booths.xlsx.axlsx index 5fe084db..33d16e72 100644 --- a/app/views/admin/booths/booths.xlsx.axlsx +++ b/app/views/admin/booths/booths.xlsx.axlsx @@ -1,3 +1,5 @@ +# frozen_string_literal: true + wb = xlsx_package.workbook xlsx_package.use_autowidth = true if @booth_export_option == 'confirmed' diff --git a/app/views/admin/events/_all_events.xlsx.axlsx b/app/views/admin/events/_all_events.xlsx.axlsx index 3197cf38..44f4deb6 100644 --- a/app/views/admin/events/_all_events.xlsx.axlsx +++ b/app/views/admin/events/_all_events.xlsx.axlsx @@ -1,6 +1,8 @@ +# frozen_string_literal: true + wb.add_worksheet(name: 'all events') do |sheet| bold_style = wb.styles.add_style(b: true) - wrap_text = wb.styles.add_style alignment: {wrap_text: true} + wrap_text = wb.styles.add_style alignment: { wrap_text: true } row = ['Event ID', 'Title', 'Abstract', @@ -20,7 +22,7 @@ wb.add_worksheet(name: 'all events') do |sheet| row << event.id row << event.title row << event.abstract - row << (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : '') + row << (event.time.present? ? "#{event.time.strftime('%Y-%m-%d')} #{event.time.strftime('%I:%M%p')} " : '') row << event.submitter.name row << event.speaker_names row << event.speaker_emails @@ -29,7 +31,7 @@ wb.add_worksheet(name: 'all events') do |sheet| row << (event.difficulty_level.present? ? event.difficulty_level.title : '') row << (event.room.present? ? event.room.name : '') row << event.state - sheet.add_row row , style: wrap_text - sheet.column_widths 10,15,35,13,18,18,28,12,15,15,15,10 + sheet.add_row row, style: wrap_text + sheet.column_widths 10, 15, 35, 13, 18, 18, 28, 12, 15, 15, 15, 10 end end diff --git a/app/views/admin/events/_all_with_comments.xlsx.axlsx b/app/views/admin/events/_all_with_comments.xlsx.axlsx index fd798ca5..8a877c79 100644 --- a/app/views/admin/events/_all_with_comments.xlsx.axlsx +++ b/app/views/admin/events/_all_with_comments.xlsx.axlsx @@ -1,3 +1,5 @@ +# frozen_string_literal: true + wb.use_shared_strings = true wb.add_worksheet(name: 'events with comments') do |sheet| bold_style = wb.styles.add_style(b: true) @@ -20,13 +22,13 @@ wb.add_worksheet(name: 'events with comments') do |sheet| @events.each do |event| all_comments = '' event.root_comments.each do |comment| - all_comments << "#{comment.created_at.strftime("%Y-%m-%d")} #{comment.created_at.strftime("%I:%M%p")} #{comment.user.name}: #{comment.body}\n" + all_comments << "#{comment.created_at.strftime('%Y-%m-%d')} #{comment.created_at.strftime('%I:%M%p')} #{comment.user.name}: #{comment.body}\n" end row = [] row << event.id row << event.title row << event.abstract - row << (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : '') + row << (event.time.present? ? "#{event.time.strftime('%Y-%m-%d')} #{event.time.strftime('%I:%M%p')} " : '') row << event.submitter.name row << event.speaker_names row << event.speaker_emails @@ -37,6 +39,6 @@ wb.add_worksheet(name: 'events with comments') do |sheet| row << event.state row << all_comments.strip sheet.add_row row, style: cell_style - sheet.column_widths 10,15,35,13,18,18,28,12,15,15,15,10 + sheet.column_widths 10, 15, 35, 13, 18, 18, 28, 12, 15, 15, 15, 10 end end diff --git a/app/views/admin/events/_confirmed_events.xlsx.axlsx b/app/views/admin/events/_confirmed_events.xlsx.axlsx index a1c8c886..204bcb5c 100644 --- a/app/views/admin/events/_confirmed_events.xlsx.axlsx +++ b/app/views/admin/events/_confirmed_events.xlsx.axlsx @@ -1,6 +1,8 @@ +# frozen_string_literal: true + wb.add_worksheet(name: 'confirmed events') do |sheet| bold_style = wb.styles.add_style(b: true) - wrap_text = wb.styles.add_style alignment: {wrap_text: true} + wrap_text = wb.styles.add_style alignment: { wrap_text: true } row = ['Event ID', 'Title', 'Abstract', @@ -20,7 +22,7 @@ wb.add_worksheet(name: 'confirmed events') do |sheet| row << event.id row << event.title row << event.abstract - row << (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : '') + row << (event.time.present? ? "#{event.time.strftime('%Y-%m-%d')} #{event.time.strftime('%I:%M%p')} " : '') row << event.submitter.name row << event.speaker_names row << event.speaker_emails @@ -29,7 +31,7 @@ wb.add_worksheet(name: 'confirmed events') do |sheet| row << (event.difficulty_level.present? ? event.difficulty_level.title : '') row << (event.room.present? ? event.room.name : '') row << event.state - sheet.add_row row , style: wrap_text - sheet.column_widths 10,15,35,13,18,18,28,12,15,15,15,10 + sheet.add_row row, style: wrap_text + sheet.column_widths 10, 15, 35, 13, 18, 18, 28, 12, 15, 15, 15, 10 end end diff --git a/app/views/admin/events/events.xlsx.axlsx b/app/views/admin/events/events.xlsx.axlsx index abfd1365..bc90bd79 100644 --- a/app/views/admin/events/events.xlsx.axlsx +++ b/app/views/admin/events/events.xlsx.axlsx @@ -1,8 +1,10 @@ +# frozen_string_literal: true + wb = xlsx_package.workbook if @event_export_option == 'confirmed' - render partial: 'confirmed_events', locals: {:wb => wb} + render partial: 'confirmed_events', locals: { wb: wb } elsif @event_export_option == 'all' - render partial: 'all_events', locals: {:wb => wb} + render partial: 'all_events', locals: { wb: wb } elsif @event_export_option == 'all_with_comments' - render partial: 'all_with_comments', locals: {:wb => wb} + render partial: 'all_with_comments', locals: { wb: wb } end diff --git a/app/views/admin/registrations/index.xlsx.axlsx b/app/views/admin/registrations/index.xlsx.axlsx index babc24ef..57fa5bb6 100644 --- a/app/views/admin/registrations/index.xlsx.axlsx +++ b/app/views/admin/registrations/index.xlsx.axlsx @@ -1,17 +1,19 @@ +# frozen_string_literal: true + wb = xlsx_package.workbook wb.add_worksheet(name: 'registrations') do |sheet| bold_style = wb.styles.add_style(b: true) - row = ['Attended', 'Name', 'Nickname', 'Affilιation', 'Email', 'Arrival', 'Departure'] + row = %w[Attended Name Nickname Affilιation Email Arrival Departure] @conference.questions.each do |question| row << question.title end - sheet.add_row row, :style => bold_style + sheet.add_row row, style: bold_style @registrations.each do |registration| row = [] - row << ( registration.attended ? 'X' : '' ) + row << (registration.attended ? 'X' : '') row << registration.name row << registration.nickname row << registration.affiliation @@ -20,7 +22,7 @@ wb.add_worksheet(name: 'registrations') do |sheet| row << registration.departure.to_s @conference.questions.each do |question| qa = registration.qanswers.find_by(question: question) - answer = ( qa ? qa.answer.title : '' ) + answer = (qa ? qa.answer.title : '') row << answer end @@ -28,4 +30,3 @@ wb.add_worksheet(name: 'registrations') do |sheet| sheet.add_row row end end - diff --git a/app/views/admin/tracks/_all_tracks.xlsx.axlsx b/app/views/admin/tracks/_all_tracks.xlsx.axlsx index d1397193..ee29fb33 100644 --- a/app/views/admin/tracks/_all_tracks.xlsx.axlsx +++ b/app/views/admin/tracks/_all_tracks.xlsx.axlsx @@ -1,6 +1,8 @@ +# frozen_string_literal: true + wb.add_worksheet(name: 'all tracks') do |sheet| bold_style = wb.styles.add_style(b: true) - wrap_text = wb.styles.add_style alignment: {wrap_text: true} + wrap_text = wb.styles.add_style alignment: { wrap_text: true } row = ['Track ID', 'Name', 'Description', @@ -23,7 +25,7 @@ wb.add_worksheet(name: 'all tracks') do |sheet| row << track.try(:submitter).try(:name) row << (track.cfp_active? ? 'Yes' : 'No') row << track.state - sheet.add_row row , style: wrap_text - sheet.column_widths 10,20,50,20,12,12,20,15,10 + sheet.add_row row, style: wrap_text + sheet.column_widths 10, 20, 50, 20, 12, 12, 20, 15, 10 end end diff --git a/app/views/admin/tracks/_confirmed_tracks.xlsx.axlsx b/app/views/admin/tracks/_confirmed_tracks.xlsx.axlsx index 673b985c..6c3c84ee 100644 --- a/app/views/admin/tracks/_confirmed_tracks.xlsx.axlsx +++ b/app/views/admin/tracks/_confirmed_tracks.xlsx.axlsx @@ -1,6 +1,8 @@ +# frozen_string_literal: true + wb.add_worksheet(name: 'all tracks') do |sheet| bold_style = wb.styles.add_style(b: true) - wrap_text = wb.styles.add_style alignment: {wrap_text: true} + wrap_text = wb.styles.add_style alignment: { wrap_text: true } row = ['Track ID', 'Name', 'Description', @@ -23,7 +25,7 @@ wb.add_worksheet(name: 'all tracks') do |sheet| row << track.try(:submitter).try(:name) row << (track.cfp_active? ? 'Yes' : 'No') row << track.state - sheet.add_row row , style: wrap_text - sheet.column_widths 10,20,50,20,12,12,20,15,10 + sheet.add_row row, style: wrap_text + sheet.column_widths 10, 20, 50, 20, 12, 12, 20, 15, 10 end end diff --git a/app/views/admin/tracks/tracks.xlsx.axlsx b/app/views/admin/tracks/tracks.xlsx.axlsx index 6a84da9b..f90b6005 100644 --- a/app/views/admin/tracks/tracks.xlsx.axlsx +++ b/app/views/admin/tracks/tracks.xlsx.axlsx @@ -1,3 +1,5 @@ +# frozen_string_literal: true + wb = xlsx_package.workbook if @track_export_option == 'confirmed' render partial: 'confirmed_tracks', locals: { wb: wb } diff --git a/config.ru b/config.ru index a0123600..ccfab02b 100644 --- a/config.ru +++ b/config.ru @@ -1,5 +1,7 @@ +# frozen_string_literal: true + # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require ::File.expand_path('../config/environment', __FILE__) use Rack::Deflater run Osem::Application diff --git a/db/migrate/20121223110942_devise_create_users.rb b/db/migrate/20121223110942_devise_create_users.rb index 60cc97dc..c566b064 100644 --- a/db/migrate/20121223110942_devise_create_users.rb +++ b/db/migrate/20121223110942_devise_create_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DeviseCreateUsers < ActiveRecord::Migration def up create_table(:users) do |t| diff --git a/db/migrate/20121223115038_create_conferences_table.rb b/db/migrate/20121223115038_create_conferences_table.rb index 932b66e7..2f2e170e 100644 --- a/db/migrate/20121223115038_create_conferences_table.rb +++ b/db/migrate/20121223115038_create_conferences_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateConferencesTable < ActiveRecord::Migration def up create_table :conferences do |t| diff --git a/db/migrate/20121223115106_create_people_table.rb b/db/migrate/20121223115106_create_people_table.rb index 75563b7d..63160bb8 100644 --- a/db/migrate/20121223115106_create_people_table.rb +++ b/db/migrate/20121223115106_create_people_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreatePeopleTable < ActiveRecord::Migration def up create_table :people do |t| diff --git a/db/migrate/20121223115117_create_rooms_table.rb b/db/migrate/20121223115117_create_rooms_table.rb index 0a45ac62..57cf72e6 100644 --- a/db/migrate/20121223115117_create_rooms_table.rb +++ b/db/migrate/20121223115117_create_rooms_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateRoomsTable < ActiveRecord::Migration def up create_table :rooms do |t| diff --git a/db/migrate/20121223115125_create_tracks_table.rb b/db/migrate/20121223115125_create_tracks_table.rb index 5680c476..067bdad1 100644 --- a/db/migrate/20121223115125_create_tracks_table.rb +++ b/db/migrate/20121223115125_create_tracks_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateTracksTable < ActiveRecord::Migration def up create_table :tracks do |t| @@ -11,6 +13,5 @@ class CreateTracksTable < ActiveRecord::Migration end end - def down - end + def down; end end diff --git a/db/migrate/20121223115135_create_events_table.rb b/db/migrate/20121223115135_create_events_table.rb index 56f14f36..6ec49ff0 100644 --- a/db/migrate/20121223115135_create_events_table.rb +++ b/db/migrate/20121223115135_create_events_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateEventsTable < ActiveRecord::Migration def up create_table :events do |t| @@ -26,6 +28,5 @@ class CreateEventsTable < ActiveRecord::Migration end end - def down - end + def down; end end diff --git a/db/migrate/20121223120413_create_event_types.rb b/db/migrate/20121223120413_create_event_types.rb index 3257ade4..f34dfa77 100644 --- a/db/migrate/20121223120413_create_event_types.rb +++ b/db/migrate/20121223120413_create_event_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateEventTypes < ActiveRecord::Migration def up create_table :event_types do |t| diff --git a/db/migrate/20121223122307_create_event_people_table.rb b/db/migrate/20121223122307_create_event_people_table.rb index 27e32a44..3ac46fa2 100644 --- a/db/migrate/20121223122307_create_event_people_table.rb +++ b/db/migrate/20121223122307_create_event_people_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateEventPeopleTable < ActiveRecord::Migration def self.up create_table :event_people do |t| diff --git a/db/migrate/20121223122842_create_venue_table.rb b/db/migrate/20121223122842_create_venue_table.rb index 38e7115f..f2a07e39 100644 --- a/db/migrate/20121223122842_create_venue_table.rb +++ b/db/migrate/20121223122842_create_venue_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateVenueTable < ActiveRecord::Migration def up create_table :venues do |t| diff --git a/db/migrate/20121223135240_create_roles_table.rb b/db/migrate/20121223135240_create_roles_table.rb index 2fa3e899..fc3b5119 100644 --- a/db/migrate/20121223135240_create_roles_table.rb +++ b/db/migrate/20121223135240_create_roles_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateRolesTable < ActiveRecord::Migration def self.up create_table :roles do |t| diff --git a/db/migrate/20121223135447_user_roles_table.rb b/db/migrate/20121223135447_user_roles_table.rb index 459b3172..70aec74c 100644 --- a/db/migrate/20121223135447_user_roles_table.rb +++ b/db/migrate/20121223135447_user_roles_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UserRolesTable < ActiveRecord::Migration def self.up create_table :roles_users, id: false do |t| diff --git a/db/migrate/20121224144728_create_cfp_table.rb b/db/migrate/20121224144728_create_cfp_table.rb index eb730271..03ef90dc 100644 --- a/db/migrate/20121224144728_create_cfp_table.rb +++ b/db/migrate/20121224144728_create_cfp_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateCfpTable < ActiveRecord::Migration def up create_table :call_for_papers do |t| diff --git a/db/migrate/20130103134212_create_registrations_table.rb b/db/migrate/20130103134212_create_registrations_table.rb index 41877ad5..c9b604d8 100644 --- a/db/migrate/20130103134212_create_registrations_table.rb +++ b/db/migrate/20130103134212_create_registrations_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateRegistrationsTable < ActiveRecord::Migration def up create_table :registrations do |t| @@ -14,6 +16,5 @@ class CreateRegistrationsTable < ActiveRecord::Migration end end - def down - end + def down; end end diff --git a/db/migrate/20130104142209_create_comments.rb b/db/migrate/20130104142209_create_comments.rb index b9c9ce79..3e49125a 100644 --- a/db/migrate/20130104142209_create_comments.rb +++ b/db/migrate/20130104142209_create_comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| diff --git a/db/migrate/20130104142839_acts_as_commentable_upgrade_migration.rb b/db/migrate/20130104142839_acts_as_commentable_upgrade_migration.rb index d70bee0f..ff53ee5c 100644 --- a/db/migrate/20130104142839_acts_as_commentable_upgrade_migration.rb +++ b/db/migrate/20130104142839_acts_as_commentable_upgrade_migration.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ActsAsCommentableUpgradeMigration < ActiveRecord::Migration def self.up rename_column :comments, :comment, :body diff --git a/db/migrate/20130105115603_create_event_attachments_table.rb b/db/migrate/20130105115603_create_event_attachments_table.rb index 0332eb03..9de9fd2d 100644 --- a/db/migrate/20130105115603_create_event_attachments_table.rb +++ b/db/migrate/20130105115603_create_event_attachments_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateEventAttachmentsTable < ActiveRecord::Migration def up create_table :event_attachments do |t| diff --git a/db/migrate/20130107112833_add_registration_dates_to_conferences_table.rb b/db/migrate/20130107112833_add_registration_dates_to_conferences_table.rb index 912c639b..5aff90b2 100644 --- a/db/migrate/20130107112833_add_registration_dates_to_conferences_table.rb +++ b/db/migrate/20130107112833_add_registration_dates_to_conferences_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRegistrationDatesToConferencesTable < ActiveRecord::Migration def change add_column :conferences, :registration_start_date, :date diff --git a/db/migrate/20130107113653_remove_cfp_and_reg_booleans_from_conferences.rb b/db/migrate/20130107113653_remove_cfp_and_reg_booleans_from_conferences.rb index 5eaa39df..78c126b2 100644 --- a/db/migrate/20130107113653_remove_cfp_and_reg_booleans_from_conferences.rb +++ b/db/migrate/20130107113653_remove_cfp_and_reg_booleans_from_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveCfpAndRegBooleansFromConferences < ActiveRecord::Migration def up remove_column :conferences, :cfp_open diff --git a/db/migrate/20130107114930_create_versions.rb b/db/migrate/20130107114930_create_versions.rb index 02694362..91d11caf 100644 --- a/db/migrate/20130107114930_create_versions.rb +++ b/db/migrate/20130107114930_create_versions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateVersions < ActiveRecord::Migration def self.up create_table :versions do |t| @@ -9,11 +11,11 @@ class CreateVersions < ActiveRecord::Migration t.text :object_changes t.datetime :created_at end - add_index :versions, [:item_type, :item_id] + add_index :versions, %i[item_type item_id] end def self.down - remove_index :versions, [:item_type, :item_id] + remove_index :versions, %i[item_type item_id] drop_table :versions end end diff --git a/db/migrate/20130113105652_create_email_table.rb b/db/migrate/20130113105652_create_email_table.rb index a7b6b3e6..8a38dfd4 100644 --- a/db/migrate/20130113105652_create_email_table.rb +++ b/db/migrate/20130113105652_create_email_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateEmailTable < ActiveRecord::Migration def up create_table :email_settings do |t| diff --git a/db/migrate/20130113132225_add_subjects_to_email_settings.rb b/db/migrate/20130113132225_add_subjects_to_email_settings.rb index 9adb821c..8242c1fb 100644 --- a/db/migrate/20130113132225_add_subjects_to_email_settings.rb +++ b/db/migrate/20130113132225_add_subjects_to_email_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSubjectsToEmailSettings < ActiveRecord::Migration def change add_column :email_settings, :registration_subject, :string diff --git a/db/migrate/20130117130949_add_logo_to_conferences_table.rb b/db/migrate/20130117130949_add_logo_to_conferences_table.rb index 454c33c9..47197b08 100644 --- a/db/migrate/20130117130949_add_logo_to_conferences_table.rb +++ b/db/migrate/20130117130949_add_logo_to_conferences_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddLogoToConferencesTable < ActiveRecord::Migration def change add_column :conferences, :logo_file_name, :string diff --git a/db/migrate/20130120104029_change_arrival_registrations_date_to_datetime.rb b/db/migrate/20130120104029_change_arrival_registrations_date_to_datetime.rb index 9872d182..326b9a12 100644 --- a/db/migrate/20130120104029_change_arrival_registrations_date_to_datetime.rb +++ b/db/migrate/20130120104029_change_arrival_registrations_date_to_datetime.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeArrivalRegistrationsDateToDatetime < ActiveRecord::Migration def up change_column :registrations, :arrival, :datetime diff --git a/db/migrate/20130131100257_add_minimum_and_maximum_abstract_lengths_to_event_types.rb b/db/migrate/20130131100257_add_minimum_and_maximum_abstract_lengths_to_event_types.rb index 9ca53b4c..240e4ed8 100644 --- a/db/migrate/20130131100257_add_minimum_and_maximum_abstract_lengths_to_event_types.rb +++ b/db/migrate/20130131100257_add_minimum_and_maximum_abstract_lengths_to_event_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddMinimumAndMaximumAbstractLengthsToEventTypes < ActiveRecord::Migration def change add_column :event_types, :minimum_abstract_length, :integer, default: 0 diff --git a/db/migrate/20130202091022_add_dietary_choice_to_conferences.rb b/db/migrate/20130202091022_add_dietary_choice_to_conferences.rb index 50287c31..b0e7a917 100644 --- a/db/migrate/20130202091022_add_dietary_choice_to_conferences.rb +++ b/db/migrate/20130202091022_add_dietary_choice_to_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDietaryChoiceToConferences < ActiveRecord::Migration def change add_column :conferences, :use_dietary_choices, :boolean, default: false diff --git a/db/migrate/20130202091051_create_dietary_choices_table.rb b/db/migrate/20130202091051_create_dietary_choices_table.rb index 464c7250..1ab353d4 100644 --- a/db/migrate/20130202091051_create_dietary_choices_table.rb +++ b/db/migrate/20130202091051_create_dietary_choices_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateDietaryChoicesTable < ActiveRecord::Migration def up create_table :dietary_choices do |t| diff --git a/db/migrate/20130202091229_add_dietary_choice_to_registration.rb b/db/migrate/20130202091229_add_dietary_choice_to_registration.rb index 5694d206..343de790 100644 --- a/db/migrate/20130202091229_add_dietary_choice_to_registration.rb +++ b/db/migrate/20130202091229_add_dietary_choice_to_registration.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDietaryChoiceToRegistration < ActiveRecord::Migration def change add_column :registrations, :dietary_choice_id, :integer diff --git a/db/migrate/20130202093137_add_dietary_text_to_registration.rb b/db/migrate/20130202093137_add_dietary_text_to_registration.rb index 3147cd3c..6a1e356d 100644 --- a/db/migrate/20130202093137_add_dietary_text_to_registration.rb +++ b/db/migrate/20130202093137_add_dietary_text_to_registration.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDietaryTextToRegistration < ActiveRecord::Migration def change add_column :registrations, :other_dietary_choice, :text diff --git a/db/migrate/20130202102024_add_handicapped_access_to_registrations.rb b/db/migrate/20130202102024_add_handicapped_access_to_registrations.rb index e98b4e2f..ad5d85da 100644 --- a/db/migrate/20130202102024_add_handicapped_access_to_registrations.rb +++ b/db/migrate/20130202102024_add_handicapped_access_to_registrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddHandicappedAccessToRegistrations < ActiveRecord::Migration def change add_column :registrations, :handicapped_access_required, :boolean, default: false diff --git a/db/migrate/20130202130737_create_supporter_level_table.rb b/db/migrate/20130202130737_create_supporter_level_table.rb index 417fe9d0..60e1d08b 100644 --- a/db/migrate/20130202130737_create_supporter_level_table.rb +++ b/db/migrate/20130202130737_create_supporter_level_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateSupporterLevelTable < ActiveRecord::Migration def up create_table :supporter_levels do |t| diff --git a/db/migrate/20130202130923_create_table_supporter_registrations.rb b/db/migrate/20130202130923_create_table_supporter_registrations.rb index 5137ebb9..00f03e64 100644 --- a/db/migrate/20130202130923_create_table_supporter_registrations.rb +++ b/db/migrate/20130202130923_create_table_supporter_registrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateTableSupporterRegistrations < ActiveRecord::Migration def up create_table :supporter_registrations do |t| diff --git a/db/migrate/20130202131932_add_use_supporter_levels_to_conferences.rb b/db/migrate/20130202131932_add_use_supporter_levels_to_conferences.rb index f201511a..53247ccc 100644 --- a/db/migrate/20130202131932_add_use_supporter_levels_to_conferences.rb +++ b/db/migrate/20130202131932_add_use_supporter_levels_to_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddUseSupporterLevelsToConferences < ActiveRecord::Migration def change add_column :conferences, :use_supporter_levels, :boolean, default: false diff --git a/db/migrate/20130206192339_rename_attending_social_events_with_partner.rb b/db/migrate/20130206192339_rename_attending_social_events_with_partner.rb index bb9dc5ad..4ab121de 100644 --- a/db/migrate/20130206192339_rename_attending_social_events_with_partner.rb +++ b/db/migrate/20130206192339_rename_attending_social_events_with_partner.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true + class RenameAttendingSocialEventsWithPartner < ActiveRecord::Migration def up rename_column :registrations, :attending_social_events_with_partner, :attending_with_partner end - def down - end + def down; end end diff --git a/db/migrate/20130211170728_add_irc_nick_to_people_table.rb b/db/migrate/20130211170728_add_irc_nick_to_people_table.rb index 36cc5c62..060b85c1 100644 --- a/db/migrate/20130211170728_add_irc_nick_to_people_table.rb +++ b/db/migrate/20130211170728_add_irc_nick_to_people_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddIrcNickToPeopleTable < ActiveRecord::Migration def change add_column :people, :irc_nickname, :string diff --git a/db/migrate/20130216070725_create_social_events_table.rb b/db/migrate/20130216070725_create_social_events_table.rb index 52ebaa06..22f89dbc 100644 --- a/db/migrate/20130216070725_create_social_events_table.rb +++ b/db/migrate/20130216070725_create_social_events_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateSocialEventsTable < ActiveRecord::Migration def up create_table :social_events do |t| diff --git a/db/migrate/20130216120112_create_registrations_social_events_table.rb b/db/migrate/20130216120112_create_registrations_social_events_table.rb index 9a783d4f..a6a98d16 100644 --- a/db/migrate/20130216120112_create_registrations_social_events_table.rb +++ b/db/migrate/20130216120112_create_registrations_social_events_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateRegistrationsSocialEventsTable < ActiveRecord::Migration def up create_table :registrations_social_events, id: false do |t| diff --git a/db/migrate/20130216122155_set_registration_defaults_to_false.rb b/db/migrate/20130216122155_set_registration_defaults_to_false.rb index bbb45d64..af13b223 100644 --- a/db/migrate/20130216122155_set_registration_defaults_to_false.rb +++ b/db/migrate/20130216122155_set_registration_defaults_to_false.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true + class SetRegistrationDefaultsToFalse < ActiveRecord::Migration def up change_column :registrations, :using_affiliated_lodging, :boolean, default: false end - def down - end + def down; end end diff --git a/db/migrate/20130216122417_add_special_needs_field_to_registrations.rb b/db/migrate/20130216122417_add_special_needs_field_to_registrations.rb index 9d438e54..9339819c 100644 --- a/db/migrate/20130216122417_add_special_needs_field_to_registrations.rb +++ b/db/migrate/20130216122417_add_special_needs_field_to_registrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSpecialNeedsFieldToRegistrations < ActiveRecord::Migration def change add_column :registrations, :other_special_needs, :text diff --git a/db/migrate/20130515125823_change_attachment_default.rb b/db/migrate/20130515125823_change_attachment_default.rb index 89701f12..4f73cf4d 100644 --- a/db/migrate/20130515125823_change_attachment_default.rb +++ b/db/migrate/20130515125823_change_attachment_default.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeAttachmentDefault < ActiveRecord::Migration def up change_column_default(:event_attachments, :public, true) diff --git a/db/migrate/20130515131420_change_venue_types.rb b/db/migrate/20130515131420_change_venue_types.rb index f588fe55..00b1cb0a 100644 --- a/db/migrate/20130515131420_change_venue_types.rb +++ b/db/migrate/20130515131420_change_venue_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeVenueTypes < ActiveRecord::Migration def up change_column :venues, :name, :text diff --git a/db/migrate/20130626095459_add_video_id_to_events.rb b/db/migrate/20130626095459_add_video_id_to_events.rb index 14f034e4..da79497f 100644 --- a/db/migrate/20130626095459_add_video_id_to_events.rb +++ b/db/migrate/20130626095459_add_video_id_to_events.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddVideoIdToEvents < ActiveRecord::Migration def change add_column :events, :video_id, :string diff --git a/db/migrate/20130705055128_add_revision_to_conference.rb b/db/migrate/20130705055128_add_revision_to_conference.rb index 728b6551..d8e3070c 100644 --- a/db/migrate/20130705055128_add_revision_to_conference.rb +++ b/db/migrate/20130705055128_add_revision_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRevisionToConference < ActiveRecord::Migration def change add_column :conferences, :revision, :integer diff --git a/db/migrate/20130711043459_create_events_registrations_table.rb b/db/migrate/20130711043459_create_events_registrations_table.rb index 0c084a9a..9275880a 100644 --- a/db/migrate/20130711043459_create_events_registrations_table.rb +++ b/db/migrate/20130711043459_create_events_registrations_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateEventsRegistrationsTable < ActiveRecord::Migration def up create_table :events_registrations, id: false do |t| diff --git a/db/migrate/20130711044247_add_require_registration_to_events.rb b/db/migrate/20130711044247_add_require_registration_to_events.rb index c89d042d..a4f2f643 100644 --- a/db/migrate/20130711044247_add_require_registration_to_events.rb +++ b/db/migrate/20130711044247_add_require_registration_to_events.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRequireRegistrationToEvents < ActiveRecord::Migration def change add_column :events, :require_registration, :boolean diff --git a/db/migrate/20130712072609_add_attended_to_registrations.rb b/db/migrate/20130712072609_add_attended_to_registrations.rb index 3a6f15ee..598f432e 100644 --- a/db/migrate/20130712072609_add_attended_to_registrations.rb +++ b/db/migrate/20130712072609_add_attended_to_registrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddAttendedToRegistrations < ActiveRecord::Migration def change add_column :registrations, :attended, :boolean, default: 0 diff --git a/db/migrate/20130728055450_add_schedule_changes_to_call_for_papers.rb b/db/migrate/20130728055450_add_schedule_changes_to_call_for_papers.rb index d0cabf03..4078efc0 100644 --- a/db/migrate/20130728055450_add_schedule_changes_to_call_for_papers.rb +++ b/db/migrate/20130728055450_add_schedule_changes_to_call_for_papers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddScheduleChangesToCallForPapers < ActiveRecord::Migration def change add_column :call_for_papers, :schedule_changes, :boolean, default: 0 diff --git a/db/migrate/20130815085420_create_votes.rb b/db/migrate/20130815085420_create_votes.rb index 1b4460a7..d0e514a6 100644 --- a/db/migrate/20130815085420_create_votes.rb +++ b/db/migrate/20130815085420_create_votes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateVotes < ActiveRecord::Migration def up create_table :votes do |t| diff --git a/db/migrate/20130815201317_add_rating_to_call_for_papers.rb b/db/migrate/20130815201317_add_rating_to_call_for_papers.rb index 1aab4ac6..b5537596 100644 --- a/db/migrate/20130815201317_add_rating_to_call_for_papers.rb +++ b/db/migrate/20130815201317_add_rating_to_call_for_papers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRatingToCallForPapers < ActiveRecord::Migration def change add_column :call_for_papers, :rating, :integer, null: 1 diff --git a/db/migrate/20130815201511_add_rating_desc_to_call_for_papers.rb b/db/migrate/20130815201511_add_rating_desc_to_call_for_papers.rb index 386a3064..67c8f020 100644 --- a/db/migrate/20130815201511_add_rating_desc_to_call_for_papers.rb +++ b/db/migrate/20130815201511_add_rating_desc_to_call_for_papers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRatingDescToCallForPapers < ActiveRecord::Migration def change add_column :call_for_papers, :rating_desc, :text diff --git a/db/migrate/20130821094246_add_volunteer_to_registrations.rb b/db/migrate/20130821094246_add_volunteer_to_registrations.rb index 98a2e3fe..b0719aab 100644 --- a/db/migrate/20130821094246_add_volunteer_to_registrations.rb +++ b/db/migrate/20130821094246_add_volunteer_to_registrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddVolunteerToRegistrations < ActiveRecord::Migration def change add_column :registrations, :volunteer, :boolean diff --git a/db/migrate/20130821102003_add_volunteer_experience_to_registrations.rb b/db/migrate/20130821102003_add_volunteer_experience_to_registrations.rb index b725d532..6621e547 100644 --- a/db/migrate/20130821102003_add_volunteer_experience_to_registrations.rb +++ b/db/migrate/20130821102003_add_volunteer_experience_to_registrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddVolunteerExperienceToRegistrations < ActiveRecord::Migration def change add_column :people, :volunteer_experience, :text diff --git a/db/migrate/20130821102047_add_tshirt_to_people.rb b/db/migrate/20130821102047_add_tshirt_to_people.rb index 9519dc91..b25b7023 100644 --- a/db/migrate/20130821102047_add_tshirt_to_people.rb +++ b/db/migrate/20130821102047_add_tshirt_to_people.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddTshirtToPeople < ActiveRecord::Migration def change add_column :people, :tshirt, :string diff --git a/db/migrate/20130821102108_add_mobile_to_people.rb b/db/migrate/20130821102108_add_mobile_to_people.rb index f4e9ae68..550b63aa 100644 --- a/db/migrate/20130821102108_add_mobile_to_people.rb +++ b/db/migrate/20130821102108_add_mobile_to_people.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddMobileToPeople < ActiveRecord::Migration def change add_column :people, :mobile, :string diff --git a/db/migrate/20130821102404_add_languages_to_people.rb b/db/migrate/20130821102404_add_languages_to_people.rb index 2ffbbb3b..3d554988 100644 --- a/db/migrate/20130821102404_add_languages_to_people.rb +++ b/db/migrate/20130821102404_add_languages_to_people.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddLanguagesToPeople < ActiveRecord::Migration def change add_column :people, :languages, :string diff --git a/db/migrate/20130821102543_add_use_vpositions_to_conferences.rb b/db/migrate/20130821102543_add_use_vpositions_to_conferences.rb index f78ccd18..25054495 100644 --- a/db/migrate/20130821102543_add_use_vpositions_to_conferences.rb +++ b/db/migrate/20130821102543_add_use_vpositions_to_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddUseVpositionsToConferences < ActiveRecord::Migration def change add_column :conferences, :use_vpositions, :boolean diff --git a/db/migrate/20130821102618_add_use_vdays_to_conferences.rb b/db/migrate/20130821102618_add_use_vdays_to_conferences.rb index 70af09c4..ce921316 100644 --- a/db/migrate/20130821102618_add_use_vdays_to_conferences.rb +++ b/db/migrate/20130821102618_add_use_vdays_to_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddUseVdaysToConferences < ActiveRecord::Migration def change add_column :conferences, :use_vdays, :boolean diff --git a/db/migrate/20130821133651_create_vpositions.rb b/db/migrate/20130821133651_create_vpositions.rb index af7fa36c..dd9d3ed4 100644 --- a/db/migrate/20130821133651_create_vpositions.rb +++ b/db/migrate/20130821133651_create_vpositions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateVpositions < ActiveRecord::Migration def up create_table :vpositions do |t| diff --git a/db/migrate/20130821133850_create_vdays.rb b/db/migrate/20130821133850_create_vdays.rb index c4d83d4c..9c05c279 100644 --- a/db/migrate/20130821133850_create_vdays.rb +++ b/db/migrate/20130821133850_create_vdays.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateVdays < ActiveRecord::Migration def up create_table :vdays do |t| diff --git a/db/migrate/20131022131450_add_created_at_to_supporter_registrations.rb b/db/migrate/20131022131450_add_created_at_to_supporter_registrations.rb index 9ec2317a..bdeede4d 100644 --- a/db/migrate/20131022131450_add_created_at_to_supporter_registrations.rb +++ b/db/migrate/20131022131450_add_created_at_to_supporter_registrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCreatedAtToSupporterRegistrations < ActiveRecord::Migration def change add_column :supporter_registrations, :created_at, :datetime diff --git a/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb b/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb index 7fe2f314..89b9fa80 100644 --- a/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb +++ b/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeDefaultRatingInCallForPapers < ActiveRecord::Migration def up change_column :call_for_papers, :rating, :integer, default: 3 diff --git a/db/migrate/20131228214532_create_vchoices.rb b/db/migrate/20131228214532_create_vchoices.rb index 04fabb75..0114f532 100644 --- a/db/migrate/20131228214532_create_vchoices.rb +++ b/db/migrate/20131228214532_create_vchoices.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateVchoices < ActiveRecord::Migration def change create_table :vchoices do |t| diff --git a/db/migrate/20131229072532_registrations_vchoices.rb b/db/migrate/20131229072532_registrations_vchoices.rb index 1c25a32f..3110ea2e 100644 --- a/db/migrate/20131229072532_registrations_vchoices.rb +++ b/db/migrate/20131229072532_registrations_vchoices.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RegistrationsVchoices < ActiveRecord::Migration def up create_table :registrations_vchoices, id: false do |t| diff --git a/db/migrate/20140109190643_create_questions.rb b/db/migrate/20140109190643_create_questions.rb index e0272cdb..e78b4d20 100644 --- a/db/migrate/20140109190643_create_questions.rb +++ b/db/migrate/20140109190643_create_questions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateQuestions < ActiveRecord::Migration def change create_table :questions do |t| diff --git a/db/migrate/20140109190844_create_question_types.rb b/db/migrate/20140109190844_create_question_types.rb index 3a2582fd..7a8f07d3 100644 --- a/db/migrate/20140109190844_create_question_types.rb +++ b/db/migrate/20140109190844_create_question_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateQuestionTypes < ActiveRecord::Migration def change create_table :question_types do |t| diff --git a/db/migrate/20140109191042_create_answers.rb b/db/migrate/20140109191042_create_answers.rb index 35394d79..5356bda7 100644 --- a/db/migrate/20140109191042_create_answers.rb +++ b/db/migrate/20140109191042_create_answers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateAnswers < ActiveRecord::Migration def change create_table :answers do |t| diff --git a/db/migrate/20140109191145_create_qanswers.rb b/db/migrate/20140109191145_create_qanswers.rb index 4b31744f..4bc39588 100644 --- a/db/migrate/20140109191145_create_qanswers.rb +++ b/db/migrate/20140109191145_create_qanswers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateQanswers < ActiveRecord::Migration def change create_table :qanswers do |t| diff --git a/db/migrate/20140109191321_create_conferences_questions.rb b/db/migrate/20140109191321_create_conferences_questions.rb index 7cb8dbaf..659de9a4 100644 --- a/db/migrate/20140109191321_create_conferences_questions.rb +++ b/db/migrate/20140109191321_create_conferences_questions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateConferencesQuestions < ActiveRecord::Migration def change create_table :conferences_questions, id: false do |t| diff --git a/db/migrate/20140112192801_create_qanswers_registrations.rb b/db/migrate/20140112192801_create_qanswers_registrations.rb index e523173a..9501defe 100644 --- a/db/migrate/20140112192801_create_qanswers_registrations.rb +++ b/db/migrate/20140112192801_create_qanswers_registrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateQanswersRegistrations < ActiveRecord::Migration def change create_table :qanswers_registrations, id: false do |t| diff --git a/db/migrate/20140212172244_create_difficulty_levels.rb b/db/migrate/20140212172244_create_difficulty_levels.rb index bdd9547c..02faced0 100644 --- a/db/migrate/20140212172244_create_difficulty_levels.rb +++ b/db/migrate/20140212172244_create_difficulty_levels.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateDifficultyLevels < ActiveRecord::Migration def change create_table :difficulty_levels do |t| diff --git a/db/migrate/20140212175251_add_use_difficulty_levels_to_conference.rb b/db/migrate/20140212175251_add_use_difficulty_levels_to_conference.rb index c60721e4..02391e2a 100644 --- a/db/migrate/20140212175251_add_use_difficulty_levels_to_conference.rb +++ b/db/migrate/20140212175251_add_use_difficulty_levels_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddUseDifficultyLevelsToConference < ActiveRecord::Migration def change add_column :conferences, :use_difficulty_levels, :boolean, default: false diff --git a/db/migrate/20140213122424_add_difficulty_level_id_to_events.rb b/db/migrate/20140213122424_add_difficulty_level_id_to_events.rb index 56bcecb6..e4594d1e 100644 --- a/db/migrate/20140213122424_add_difficulty_level_id_to_events.rb +++ b/db/migrate/20140213122424_add_difficulty_level_id_to_events.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDifficultyLevelIdToEvents < ActiveRecord::Migration def change add_column :events, :difficulty_level_id, :integer diff --git a/db/migrate/20140304192527_add_use_volunteers_to_conference.rb b/db/migrate/20140304192527_add_use_volunteers_to_conference.rb index 568aeec5..d7c030fa 100644 --- a/db/migrate/20140304192527_add_use_volunteers_to_conference.rb +++ b/db/migrate/20140304192527_add_use_volunteers_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddUseVolunteersToConference < ActiveRecord::Migration def change add_column :conferences, :use_volunteers, :boolean diff --git a/db/migrate/20140305102505_use_vdays_vpositions_defaults.rb b/db/migrate/20140305102505_use_vdays_vpositions_defaults.rb index 4ab07be9..052ea315 100644 --- a/db/migrate/20140305102505_use_vdays_vpositions_defaults.rb +++ b/db/migrate/20140305102505_use_vdays_vpositions_defaults.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UseVdaysVpositionsDefaults < ActiveRecord::Migration def up change_column :conferences, :use_vpositions, :boolean, default: false diff --git a/db/migrate/20140319143547_rename_video_to_media_on_events.rb b/db/migrate/20140319143547_rename_video_to_media_on_events.rb index 754c8af4..f5d6d771 100644 --- a/db/migrate/20140319143547_rename_video_to_media_on_events.rb +++ b/db/migrate/20140319143547_rename_video_to_media_on_events.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameVideoToMediaOnEvents < ActiveRecord::Migration def up rename_column :events, :video_id, :media_id diff --git a/db/migrate/20140401094729_add_schedule_public_to_call_for_papers.rb b/db/migrate/20140401094729_add_schedule_public_to_call_for_papers.rb index f08d925c..fb82814f 100644 --- a/db/migrate/20140401094729_add_schedule_public_to_call_for_papers.rb +++ b/db/migrate/20140401094729_add_schedule_public_to_call_for_papers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSchedulePublicToCallForPapers < ActiveRecord::Migration def change add_column :call_for_papers, :schedule_public, :boolean diff --git a/db/migrate/20140414131028_add_video_to_conferences.rb b/db/migrate/20140414131028_add_video_to_conferences.rb index 3fbe01b8..ea781109 100644 --- a/db/migrate/20140414131028_add_video_to_conferences.rb +++ b/db/migrate/20140414131028_add_video_to_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddVideoToConferences < ActiveRecord::Migration def change add_column :conferences, :media_id, :string diff --git a/db/migrate/20140514140013_remove_rating_desc_from_cfp.rb b/db/migrate/20140514140013_remove_rating_desc_from_cfp.rb index c8bd9bb4..8f25368d 100644 --- a/db/migrate/20140514140013_remove_rating_desc_from_cfp.rb +++ b/db/migrate/20140514140013_remove_rating_desc_from_cfp.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveRatingDescFromCfp < ActiveRecord::Migration def up remove_column :call_for_papers, :rating_desc diff --git a/db/migrate/20140528072939_add_color_to_conference.rb b/db/migrate/20140528072939_add_color_to_conference.rb index c3f83980..37aa6f99 100644 --- a/db/migrate/20140528072939_add_color_to_conference.rb +++ b/db/migrate/20140528072939_add_color_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddColorToConference < ActiveRecord::Migration def change add_column :conferences, :color, :string, default: '#000000' diff --git a/db/migrate/20140528084706_add_description_to_conference.rb b/db/migrate/20140528084706_add_description_to_conference.rb index 0cb7291d..9e1612fc 100644 --- a/db/migrate/20140528084706_add_description_to_conference.rb +++ b/db/migrate/20140528084706_add_description_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDescriptionToConference < ActiveRecord::Migration def change add_column :conferences, :description, :text diff --git a/db/migrate/20140528115842_add_registration_description_to_conference.rb b/db/migrate/20140528115842_add_registration_description_to_conference.rb index b893de72..3886549a 100644 --- a/db/migrate/20140528115842_add_registration_description_to_conference.rb +++ b/db/migrate/20140528115842_add_registration_description_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRegistrationDescriptionToConference < ActiveRecord::Migration def change add_column :conferences, :registration_description, :text diff --git a/db/migrate/20140529133052_add_ticket_description_to_conference.rb b/db/migrate/20140529133052_add_ticket_description_to_conference.rb index ccb610d9..bbd4b997 100644 --- a/db/migrate/20140529133052_add_ticket_description_to_conference.rb +++ b/db/migrate/20140529133052_add_ticket_description_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddTicketDescriptionToConference < ActiveRecord::Migration def change add_column :conferences, :ticket_description, :text diff --git a/db/migrate/20140529133228_add_description_to_supporter_level.rb b/db/migrate/20140529133228_add_description_to_supporter_level.rb index 4473c851..68b04806 100644 --- a/db/migrate/20140529133228_add_description_to_supporter_level.rb +++ b/db/migrate/20140529133228_add_description_to_supporter_level.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDescriptionToSupporterLevel < ActiveRecord::Migration def change add_column :supporter_levels, :description, :text diff --git a/db/migrate/20140529133339_add_ticket_price_to_supporter_level.rb b/db/migrate/20140529133339_add_ticket_price_to_supporter_level.rb index c7ac5002..cc993529 100644 --- a/db/migrate/20140529133339_add_ticket_price_to_supporter_level.rb +++ b/db/migrate/20140529133339_add_ticket_price_to_supporter_level.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddTicketPriceToSupporterLevel < ActiveRecord::Migration def change add_column :supporter_levels, :ticket_price, :string diff --git a/db/migrate/20140530082708_remove_color_defaults.rb b/db/migrate/20140530082708_remove_color_defaults.rb index 4292ecca..d5b7fe50 100644 --- a/db/migrate/20140530082708_remove_color_defaults.rb +++ b/db/migrate/20140530082708_remove_color_defaults.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveColorDefaults < ActiveRecord::Migration def change change_column_default(:tracks, :color, nil) diff --git a/db/migrate/20140603092041_create_openids.rb b/db/migrate/20140603092041_create_openids.rb index 4ca63029..93cf271d 100644 --- a/db/migrate/20140603092041_create_openids.rb +++ b/db/migrate/20140603092041_create_openids.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateOpenids < ActiveRecord::Migration def change create_table :openids do |t| diff --git a/db/migrate/20140604061951_create_lodgings.rb b/db/migrate/20140604061951_create_lodgings.rb index 45412bcc..e9192e33 100644 --- a/db/migrate/20140604061951_create_lodgings.rb +++ b/db/migrate/20140604061951_create_lodgings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateLodgings < ActiveRecord::Migration def change create_table :lodgings do |t| diff --git a/db/migrate/20140604142949_remove_hard_deadline_from_call_for_papers.rb b/db/migrate/20140604142949_remove_hard_deadline_from_call_for_papers.rb index 7d567199..b1e3d052 100644 --- a/db/migrate/20140604142949_remove_hard_deadline_from_call_for_papers.rb +++ b/db/migrate/20140604142949_remove_hard_deadline_from_call_for_papers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveHardDeadlineFromCallForPapers < ActiveRecord::Migration def up remove_column :call_for_papers, :hard_deadline diff --git a/db/migrate/20140605055802_create_sponsorship_levels.rb b/db/migrate/20140605055802_create_sponsorship_levels.rb index 1a93980b..e192b2c1 100644 --- a/db/migrate/20140605055802_create_sponsorship_levels.rb +++ b/db/migrate/20140605055802_create_sponsorship_levels.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateSponsorshipLevels < ActiveRecord::Migration def change create_table :sponsorship_levels do |t| diff --git a/db/migrate/20140605115251_create_sponsors.rb b/db/migrate/20140605115251_create_sponsors.rb index 0c3bd063..fb2751d2 100644 --- a/db/migrate/20140605115251_create_sponsors.rb +++ b/db/migrate/20140605115251_create_sponsors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateSponsors < ActiveRecord::Migration def change create_table :sponsors do |t| diff --git a/db/migrate/20140605125153_update_event_states.rb b/db/migrate/20140605125153_update_event_states.rb index b4a888c6..e5302c8e 100644 --- a/db/migrate/20140605125153_update_event_states.rb +++ b/db/migrate/20140605125153_update_event_states.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UpdateEventStates < ActiveRecord::Migration def change execute "UPDATE events SET state='new' WHERE state = 'review';" diff --git a/db/migrate/20140606102331_add_sponsor_description_to_conference.rb b/db/migrate/20140606102331_add_sponsor_description_to_conference.rb index 39d6de6e..eb01d770 100644 --- a/db/migrate/20140606102331_add_sponsor_description_to_conference.rb +++ b/db/migrate/20140606102331_add_sponsor_description_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSponsorDescriptionToConference < ActiveRecord::Migration def change add_column :conferences, :sponsor_description, :text diff --git a/db/migrate/20140606102358_add_sponsor_email_to_conference.rb b/db/migrate/20140606102358_add_sponsor_email_to_conference.rb index 7dc0b56e..7446746b 100644 --- a/db/migrate/20140606102358_add_sponsor_email_to_conference.rb +++ b/db/migrate/20140606102358_add_sponsor_email_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSponsorEmailToConference < ActiveRecord::Migration def change add_column :conferences, :sponsor_email, :string diff --git a/db/migrate/20140609172219_add_person_attributes_to_user.rb b/db/migrate/20140609172219_add_person_attributes_to_user.rb index 140d7771..e9b1fcee 100644 --- a/db/migrate/20140609172219_add_person_attributes_to_user.rb +++ b/db/migrate/20140609172219_add_person_attributes_to_user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPersonAttributesToUser < ActiveRecord::Migration def change add_column :users, :name, :string diff --git a/db/migrate/20140610064046_create_photos.rb b/db/migrate/20140610064046_create_photos.rb index 846b7934..5e1aab05 100644 --- a/db/migrate/20140610064046_create_photos.rb +++ b/db/migrate/20140610064046_create_photos.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreatePhotos < ActiveRecord::Migration def change create_table :photos do |t| diff --git a/db/migrate/20140610163947_create_event_users.rb b/db/migrate/20140610163947_create_event_users.rb index 7d0fdbe3..668b3006 100644 --- a/db/migrate/20140610163947_create_event_users.rb +++ b/db/migrate/20140610163947_create_event_users.rb @@ -1,13 +1,15 @@ +# frozen_string_literal: true + class CreateEventUsers < ActiveRecord::Migration - class TempPerson < ActiveRecord::Base + class TempPerson < ApplicationRecord self.table_name = 'people' end - class TempEventPerson < ActiveRecord::Base + class TempEventPerson < ApplicationRecord self.table_name = 'event_people' end - class TempEventUser < ActiveRecord::Base + class TempEventUser < ApplicationRecord self.table_name = 'event_users' end diff --git a/db/migrate/20140610165551_migrate_data_person_to_user.rb b/db/migrate/20140610165551_migrate_data_person_to_user.rb index d606ba28..7743b324 100644 --- a/db/migrate/20140610165551_migrate_data_person_to_user.rb +++ b/db/migrate/20140610165551_migrate_data_person_to_user.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + class MigrateDataPersonToUser < ActiveRecord::Migration - class TempPerson < ActiveRecord::Base + class TempPerson < ApplicationRecord self.table_name = 'people' end - class TempUser < ActiveRecord::Base + class TempUser < ApplicationRecord self.table_name = 'users' end @@ -11,11 +13,11 @@ class MigrateDataPersonToUser < ActiveRecord::Migration TempPerson.all.each do |p| user = TempUser.find_by(id: p.user_id) next unless user - if p.public_name.empty? - user.name = p.email - else - user.name = p.public_name - end + user.name = if p.public_name.empty? + p.email + else + p.public_name + end user.biography = p.biography user.nickname = p.irc_nickname user.affiliation = p.company diff --git a/db/migrate/20140610173021_change_person_id_to_user_id_in_registrations.rb b/db/migrate/20140610173021_change_person_id_to_user_id_in_registrations.rb index ac54e435..d592a118 100644 --- a/db/migrate/20140610173021_change_person_id_to_user_id_in_registrations.rb +++ b/db/migrate/20140610173021_change_person_id_to_user_id_in_registrations.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + class ChangePersonIdToUserIdInRegistrations < ActiveRecord::Migration - class TempPerson < ActiveRecord::Base + class TempPerson < ApplicationRecord self.table_name = 'people' end - class TempRegistration < ActiveRecord::Base + class TempRegistration < ApplicationRecord self.table_name = 'registrations' end @@ -13,11 +15,10 @@ class ChangePersonIdToUserIdInRegistrations < ActiveRecord::Migration TempPerson.all.each do |t| registrations = TempRegistration.where(person_id: t.id) - unless registrations.empty? - registrations.each do |r| - r.user_id = t.user_id - r.save! - end + next if registrations.empty? + registrations.each do |r| + r.user_id = t.user_id + r.save! end end diff --git a/db/migrate/20140611123926_change_person_id_to_user_id_in_votes.rb b/db/migrate/20140611123926_change_person_id_to_user_id_in_votes.rb index 973f0001..7073d345 100644 --- a/db/migrate/20140611123926_change_person_id_to_user_id_in_votes.rb +++ b/db/migrate/20140611123926_change_person_id_to_user_id_in_votes.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + class ChangePersonIdToUserIdInVotes < ActiveRecord::Migration - class TempPerson < ActiveRecord::Base + class TempPerson < ApplicationRecord self.table_name = 'people' end - class TempVote < ActiveRecord::Base + class TempVote < ApplicationRecord self.table_name = 'votes' end @@ -13,11 +15,10 @@ class ChangePersonIdToUserIdInVotes < ActiveRecord::Migration TempPerson.all.each do |t| votes = TempVote.where(person_id: t.id) - unless votes.empty? - votes.each do |v| - v.user_id = t.user_id - v.save! - end + next if votes.empty? + votes.each do |v| + v.user_id = t.user_id + v.save! end end diff --git a/db/migrate/20140612141123_add_color_to_event_type.rb b/db/migrate/20140612141123_add_color_to_event_type.rb index 210256ea..ffe250a4 100644 --- a/db/migrate/20140612141123_add_color_to_event_type.rb +++ b/db/migrate/20140612141123_add_color_to_event_type.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddColorToEventType < ActiveRecord::Migration def change add_column :event_types, :color, :string diff --git a/db/migrate/20140612181230_add_social_urls_to_conference.rb b/db/migrate/20140612181230_add_social_urls_to_conference.rb index 5144cbd2..44cd3373 100644 --- a/db/migrate/20140612181230_add_social_urls_to_conference.rb +++ b/db/migrate/20140612181230_add_social_urls_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSocialUrlsToConference < ActiveRecord::Migration def change add_column :conferences, :twitter_url, :string diff --git a/db/migrate/20140613083115_add_photo_to_venue.rb b/db/migrate/20140613083115_add_photo_to_venue.rb index c2d0454c..8d2f7a52 100644 --- a/db/migrate/20140613083115_add_photo_to_venue.rb +++ b/db/migrate/20140613083115_add_photo_to_venue.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPhotoToVenue < ActiveRecord::Migration def change add_column :venues, :photo_file_name, :string diff --git a/db/migrate/20140614171853_add_lodging_description_to_conference.rb b/db/migrate/20140614171853_add_lodging_description_to_conference.rb index 37dd2c30..7e34573a 100644 --- a/db/migrate/20140614171853_add_lodging_description_to_conference.rb +++ b/db/migrate/20140614171853_add_lodging_description_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddLodgingDescriptionToConference < ActiveRecord::Migration def change add_column :conferences, :lodging_description, :text diff --git a/db/migrate/20140614174354_add_website_link_to_lodging.rb b/db/migrate/20140614174354_add_website_link_to_lodging.rb index 63c37bb3..d7f6d809 100644 --- a/db/migrate/20140614174354_add_website_link_to_lodging.rb +++ b/db/migrate/20140614174354_add_website_link_to_lodging.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddWebsiteLinkToLodging < ActiveRecord::Migration def change add_column :lodgings, :website_link, :string diff --git a/db/migrate/20140616131731_add_make_conference_public_to_conference.rb b/db/migrate/20140616131731_add_make_conference_public_to_conference.rb index 9cf9195b..20c41a52 100644 --- a/db/migrate/20140616131731_add_make_conference_public_to_conference.rb +++ b/db/migrate/20140616131731_add_make_conference_public_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddMakeConferencePublicToConference < ActiveRecord::Migration def change add_column :conferences, :make_conference_public, :boolean, default: false diff --git a/db/migrate/20140616132153_create_targets.rb b/db/migrate/20140616132153_create_targets.rb index 0295816e..3f5e4b7e 100644 --- a/db/migrate/20140616132153_create_targets.rb +++ b/db/migrate/20140616132153_create_targets.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateTargets < ActiveRecord::Migration def change create_table :targets do |t| diff --git a/db/migrate/20140616132456_create_campaigns.rb b/db/migrate/20140616132456_create_campaigns.rb index 9e696b68..edb06d58 100644 --- a/db/migrate/20140616132456_create_campaigns.rb +++ b/db/migrate/20140616132456_create_campaigns.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateCampaigns < ActiveRecord::Migration def change create_table :campaigns do |t| diff --git a/db/migrate/20140617140018_add_checkboxes_for_splash_components_to_conference.rb b/db/migrate/20140617140018_add_checkboxes_for_splash_components_to_conference.rb index 5822c6cd..a716507c 100644 --- a/db/migrate/20140617140018_add_checkboxes_for_splash_components_to_conference.rb +++ b/db/migrate/20140617140018_add_checkboxes_for_splash_components_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCheckboxesForSplashComponentsToConference < ActiveRecord::Migration def change add_column :conferences, :include_registrations_in_splash, :boolean, default: false diff --git a/db/migrate/20140617141918_add_include_cfp_in_splash_to_call_for_papers.rb b/db/migrate/20140617141918_add_include_cfp_in_splash_to_call_for_papers.rb index 415927e4..e8ab8e23 100644 --- a/db/migrate/20140617141918_add_include_cfp_in_splash_to_call_for_papers.rb +++ b/db/migrate/20140617141918_add_include_cfp_in_splash_to_call_for_papers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddIncludeCfpInSplashToCallForPapers < ActiveRecord::Migration def change add_column :call_for_papers, :include_cfp_in_splash, :boolean, default: false diff --git a/db/migrate/20140617145048_add_venue_checkboxes_to_venue.rb b/db/migrate/20140617145048_add_venue_checkboxes_to_venue.rb index eeb7bfea..fc6d82d3 100644 --- a/db/migrate/20140617145048_add_venue_checkboxes_to_venue.rb +++ b/db/migrate/20140617145048_add_venue_checkboxes_to_venue.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddVenueCheckboxesToVenue < ActiveRecord::Migration def change add_column :venues, :include_venue_in_splash, :boolean, default: false diff --git a/db/migrate/20140620130306_add_banner_photo_to_conference.rb b/db/migrate/20140620130306_add_banner_photo_to_conference.rb index 37b66b6e..c6ca6ecc 100644 --- a/db/migrate/20140620130306_add_banner_photo_to_conference.rb +++ b/db/migrate/20140620130306_add_banner_photo_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddBannerPhotoToConference < ActiveRecord::Migration def change add_column :conferences, :banner_photo_file_name, :string diff --git a/db/migrate/20140620134535_add_include_banner_in_splash_to_conference.rb b/db/migrate/20140620134535_add_include_banner_in_splash_to_conference.rb index 99e72412..229172ea 100644 --- a/db/migrate/20140620134535_add_include_banner_in_splash_to_conference.rb +++ b/db/migrate/20140620134535_add_include_banner_in_splash_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddIncludeBannerInSplashToConference < ActiveRecord::Migration def change add_column :conferences, :include_banner_in_splash, :boolean, default: false diff --git a/db/migrate/20140623100942_create_visits.rb b/db/migrate/20140623100942_create_visits.rb index 561fa177..49d409b6 100644 --- a/db/migrate/20140623100942_create_visits.rb +++ b/db/migrate/20140623100942_create_visits.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateVisits < ActiveRecord::Migration def change create_table :visits do |t| diff --git a/db/migrate/20140623101032_create_ahoy_events.rb b/db/migrate/20140623101032_create_ahoy_events.rb index c865a59c..7e873a75 100644 --- a/db/migrate/20140623101032_create_ahoy_events.rb +++ b/db/migrate/20140623101032_create_ahoy_events.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + class CreateAhoyEvents < ActiveRecord::Migration def change - create_table :ahoy_events do |t| + create_table :ahoy_events do |t| t.uuid :visit_id # user t.integer :user_id diff --git a/db/migrate/20140623150541_drop_person_and_event_person_tables.rb b/db/migrate/20140623150541_drop_person_and_event_person_tables.rb index d83ae15b..779f4450 100644 --- a/db/migrate/20140623150541_drop_person_and_event_person_tables.rb +++ b/db/migrate/20140623150541_drop_person_and_event_person_tables.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DropPersonAndEventPersonTables < ActiveRecord::Migration def change drop_table :people diff --git a/db/migrate/20140625112608_add_week_to_event.rb b/db/migrate/20140625112608_add_week_to_event.rb index 72d05389..a5f45bbc 100644 --- a/db/migrate/20140625112608_add_week_to_event.rb +++ b/db/migrate/20140625112608_add_week_to_event.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class AddWeekToEvent < ActiveRecord::Migration - class Event < ActiveRecord::Base + class Event < ApplicationRecord end def up diff --git a/db/migrate/20140625114813_add_week_to_registration.rb b/db/migrate/20140625114813_add_week_to_registration.rb index 29484a79..14b97c4a 100644 --- a/db/migrate/20140625114813_add_week_to_registration.rb +++ b/db/migrate/20140625114813_add_week_to_registration.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class AddWeekToRegistration < ActiveRecord::Migration - class Registration < ActiveRecord::Base + class Registration < ApplicationRecord end def up diff --git a/db/migrate/20140627165718_add_instagram_url_to_conference.rb b/db/migrate/20140627165718_add_instagram_url_to_conference.rb index d405bbc4..bb6859d9 100644 --- a/db/migrate/20140627165718_add_instagram_url_to_conference.rb +++ b/db/migrate/20140627165718_add_instagram_url_to_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddInstagramUrlToConference < ActiveRecord::Migration def change add_column :conferences, :instagram_url, :string diff --git a/db/migrate/20140701123203_add_events_per_week_to_conference.rb b/db/migrate/20140701123203_add_events_per_week_to_conference.rb index 2b4d3342..646ac9ea 100644 --- a/db/migrate/20140701123203_add_events_per_week_to_conference.rb +++ b/db/migrate/20140701123203_add_events_per_week_to_conference.rb @@ -1,14 +1,16 @@ +# frozen_string_literal: true + class AddEventsPerWeekToConference < ActiveRecord::Migration - class TempVersion < ActiveRecord::Base + class TempVersion < ApplicationRecord self.table_name = 'versions' serialize :object_changes, HashWithIndifferentAccess end - class TempEvent < ActiveRecord::Base + class TempEvent < ApplicationRecord self.table_name = 'events' end - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' serialize :events_per_week, Hash end @@ -18,56 +20,54 @@ class AddEventsPerWeekToConference < ActiveRecord::Migration TempConference.reset_column_information TempVersion.where(item_type: 'Event').each do |event_version| - event = TempEvent.find_by_id(event_version.item_id) - if event - conference = TempConference.find_by_id(event.conference_id) - if conference - week = event_version.created_at.end_of_week + event = TempEvent.find_by(id: event_version.item_id) + next unless event + conference = TempConference.find_by(id: event.conference_id) + next unless conference + week = event_version.created_at.end_of_week - no_events = { - new: 0, - withdrawn: 0, - unconfirmed: 0, - confirmed: 0, - canceled: 0, - rejected: 0, - } + no_events = { + new: 0, + withdrawn: 0, + unconfirmed: 0, + confirmed: 0, + canceled: 0, + rejected: 0 + } - if !conference.events_per_week - conference.events_per_week = { - week => no_events - } - elsif !conference.events_per_week[week] - conference.events_per_week[week] = no_events - end - - if event_version.object_changes && - event_version.event == 'create' - - # Increment the new state - conference.events_per_week[week][:new] += 1 - elsif event_version.object_changes && - event_version.object_changes[:state] - - prev_state = event_version.object_changes[:state][0].to_sym - next_state = event_version.object_changes[:state][1].to_sym - - # Backward compatibility: deprecated state :review now :new - if prev_state == :review - prev_state = :new - elsif next_state == :review - next_state = :new - end - - # Increment the next state - conference.events_per_week[week][next_state] += 1 - - # Decrement the previous state - conference.events_per_week[week][prev_state] -= 1 - end - conference.save - end + if !conference.events_per_week + conference.events_per_week = { + week => no_events + } + elsif !conference.events_per_week[week] + conference.events_per_week[week] = no_events end + + if event_version.object_changes && + event_version.event == 'create' + + # Increment the new state + conference.events_per_week[week][:new] += 1 + elsif event_version.object_changes && + event_version.object_changes[:state] + + prev_state = event_version.object_changes[:state][0].to_sym + next_state = event_version.object_changes[:state][1].to_sym + + # Backward compatibility: deprecated state :review now :new + if prev_state == :review + prev_state = :new + elsif next_state == :review + next_state = :new + end + + # Increment the next state + conference.events_per_week[week][next_state] += 1 + + # Decrement the previous state + conference.events_per_week[week][prev_state] -= 1 + end + conference.save end # Cumulate the previous weeks to get a snapshot diff --git a/db/migrate/20140707120158_add_conference_dates_updates_to_email_settings.rb b/db/migrate/20140707120158_add_conference_dates_updates_to_email_settings.rb index 24889597..6755eb36 100644 --- a/db/migrate/20140707120158_add_conference_dates_updates_to_email_settings.rb +++ b/db/migrate/20140707120158_add_conference_dates_updates_to_email_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddConferenceDatesUpdatesToEmailSettings < ActiveRecord::Migration def change add_column :email_settings, :send_on_updated_conference_dates, :boolean, default: true diff --git a/db/migrate/20140710130608_add_conference_registration_dates_updates_to_email_settings.rb b/db/migrate/20140710130608_add_conference_registration_dates_updates_to_email_settings.rb index 6313619b..6c33a5a3 100644 --- a/db/migrate/20140710130608_add_conference_registration_dates_updates_to_email_settings.rb +++ b/db/migrate/20140710130608_add_conference_registration_dates_updates_to_email_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddConferenceRegistrationDatesUpdatesToEmailSettings < ActiveRecord::Migration def change add_column :email_settings, :send_on_updated_conference_registration_dates, :boolean, default: true diff --git a/db/migrate/20140711072651_add_description_and_resource_to_roles.rb b/db/migrate/20140711072651_add_description_and_resource_to_roles.rb index 8e5a16ec..7243d268 100644 --- a/db/migrate/20140711072651_add_description_and_resource_to_roles.rb +++ b/db/migrate/20140711072651_add_description_and_resource_to_roles.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + class AddDescriptionAndResourceToRoles < ActiveRecord::Migration def change add_column :roles, :description, :string add_reference :roles, :resource, polymorphic: true add_index(:roles, :name) - add_index(:roles, [:name, :resource_type, :resource_id]) - add_index(:roles_users, [:user_id, :role_id]) + add_index(:roles, %i[name resource_type resource_id]) + add_index(:roles_users, %i[user_id role_id]) end end diff --git a/db/migrate/20140711113037_add_venue_update_to_email_settings.rb b/db/migrate/20140711113037_add_venue_update_to_email_settings.rb index 9280181b..a03d1704 100644 --- a/db/migrate/20140711113037_add_venue_update_to_email_settings.rb +++ b/db/migrate/20140711113037_add_venue_update_to_email_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddVenueUpdateToEmailSettings < ActiveRecord::Migration def change add_column :email_settings, :send_on_venue_update, :boolean, default: true diff --git a/db/migrate/20140714141156_add_volunteer_fields_to_user.rb b/db/migrate/20140714141156_add_volunteer_fields_to_user.rb index cf69a37f..293b179d 100644 --- a/db/migrate/20140714141156_add_volunteer_fields_to_user.rb +++ b/db/migrate/20140714141156_add_volunteer_fields_to_user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddVolunteerFieldsToUser < ActiveRecord::Migration def change add_column :users, :mobile, :string diff --git a/db/migrate/20140716115448_add_default_value_to_email_settings.rb b/db/migrate/20140716115448_add_default_value_to_email_settings.rb index 947aca55..404219fa 100644 --- a/db/migrate/20140716115448_add_default_value_to_email_settings.rb +++ b/db/migrate/20140716115448_add_default_value_to_email_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDefaultValueToEmailSettings < ActiveRecord::Migration def up change_column :email_settings, :send_on_registration, :boolean, default: false diff --git a/db/migrate/20140718103856_add_is_admin_to_users.rb b/db/migrate/20140718103856_add_is_admin_to_users.rb index 1511d822..de524058 100644 --- a/db/migrate/20140718103856_add_is_admin_to_users.rb +++ b/db/migrate/20140718103856_add_is_admin_to_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddIsAdminToUsers < ActiveRecord::Migration def change add_column :users, :is_admin, :boolean, default: false diff --git a/db/migrate/20140719160903_create_delayed_jobs.rb b/db/migrate/20140719160903_create_delayed_jobs.rb index ee7515c2..e9e32d0f 100644 --- a/db/migrate/20140719160903_create_delayed_jobs.rb +++ b/db/migrate/20140719160903_create_delayed_jobs.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + class CreateDelayedJobs < ActiveRecord::Migration def self.up create_table :delayed_jobs, force: true do |table| table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually. - table.text :handler, null: false # YAML-encoded string of the object that will do work + table.text :handler, null: false # YAML-encoded string of the object that will do work table.text :last_error # reason for last failure (See Note below) table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future. table.datetime :locked_at # Set when a client is working on this object @@ -13,7 +15,7 @@ class CreateDelayedJobs < ActiveRecord::Migration table.timestamps end - add_index :delayed_jobs, [:priority, :run_at], name: 'delayed_jobs_priority' + add_index :delayed_jobs, %i[priority run_at], name: 'delayed_jobs_priority' end def self.down diff --git a/db/migrate/20140724113107_add_call_for_papers_updates_to_email_settings.rb b/db/migrate/20140724113107_add_call_for_papers_updates_to_email_settings.rb index b7f0e6bb..dc4206b3 100644 --- a/db/migrate/20140724113107_add_call_for_papers_updates_to_email_settings.rb +++ b/db/migrate/20140724113107_add_call_for_papers_updates_to_email_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCallForPapersUpdatesToEmailSettings < ActiveRecord::Migration def change add_column :email_settings, :send_on_call_for_papers_dates_updates, :boolean, default: false diff --git a/db/migrate/20140724153520_create_subscriptions.rb b/db/migrate/20140724153520_create_subscriptions.rb index 25124489..80a246df 100644 --- a/db/migrate/20140724153520_create_subscriptions.rb +++ b/db/migrate/20140724153520_create_subscriptions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateSubscriptions < ActiveRecord::Migration def change create_table :subscriptions do |t| diff --git a/db/migrate/20140730104658_migrate_roles_for_cancancan.rb b/db/migrate/20140730104658_migrate_roles_for_cancancan.rb index d4259863..04f93632 100644 --- a/db/migrate/20140730104658_migrate_roles_for_cancancan.rb +++ b/db/migrate/20140730104658_migrate_roles_for_cancancan.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MigrateRolesForCancancan < ActiveRecord::Migration def up # Store the number of existing roles @@ -17,12 +19,10 @@ class MigrateRolesForCancancan < ActiveRecord::Migration end # Delete old roles - Role.first(old_roles).each do |role| - role.destroy - end + Role.first(old_roles).each(&:destroy) end def down - raise ActiveRecord::IrreversibleMigration.new('Cannot reverse migration.') + raise ActiveRecord::IrreversibleMigration, 'Cannot reverse migration.' end end diff --git a/db/migrate/20140731153332_create_contacts.rb b/db/migrate/20140731153332_create_contacts.rb index df1b3ce7..db76cd09 100644 --- a/db/migrate/20140731153332_create_contacts.rb +++ b/db/migrate/20140731153332_create_contacts.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateContacts < ActiveRecord::Migration def change create_table :contacts do |t| diff --git a/db/migrate/20140731165107_move_conference_contact_details_to_contact.rb b/db/migrate/20140731165107_move_conference_contact_details_to_contact.rb index 6098c024..97dce34b 100644 --- a/db/migrate/20140731165107_move_conference_contact_details_to_contact.rb +++ b/db/migrate/20140731165107_move_conference_contact_details_to_contact.rb @@ -1,25 +1,26 @@ +# frozen_string_literal: true + class MoveConferenceContactDetailsToContact < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' end - class TempContact < ActiveRecord::Base + class TempContact < ApplicationRecord self.table_name = 'contacts' end def change # Move all the settings to the new object TempConference.all.each do |conference| - unless TempContact.exists?(conference_id: conference.id) - TempContact.create(social_tag: conference.social_tag, - email: conference.contact_email, - facebook: conference.facebook_url, - googleplus: conference.google_url, - twitter: conference.twitter_url, - instagram: conference.instagram_url, - public: conference.include_social_media_in_splash, - conference_id: conference.id) - end + next if TempContact.exists?(conference_id: conference.id) + TempContact.create(social_tag: conference.social_tag, + email: conference.contact_email, + facebook: conference.facebook_url, + googleplus: conference.google_url, + twitter: conference.twitter_url, + instagram: conference.instagram_url, + public: conference.include_social_media_in_splash, + conference_id: conference.id) end # Then remove all the columns remove_column :conferences, :social_tag diff --git a/db/migrate/20140801103645_create_commercials.rb b/db/migrate/20140801103645_create_commercials.rb index 62074a6f..bc73fb82 100644 --- a/db/migrate/20140801103645_create_commercials.rb +++ b/db/migrate/20140801103645_create_commercials.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateCommercials < ActiveRecord::Migration def change create_table :commercials do |t| diff --git a/db/migrate/20140801164901_move_conference_media_to_commercial.rb b/db/migrate/20140801164901_move_conference_media_to_commercial.rb index d22f541c..5baf1e62 100644 --- a/db/migrate/20140801164901_move_conference_media_to_commercial.rb +++ b/db/migrate/20140801164901_move_conference_media_to_commercial.rb @@ -1,23 +1,23 @@ +# frozen_string_literal: true + class MoveConferenceMediaToCommercial < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' end - class TempCommercial < ActiveRecord::Base + class TempCommercial < ApplicationRecord self.table_name = 'commercials' end def change # Move all the settings to the new object TempConference.all.each do |conference| - unless TempCommercial.exists?(commercialable_id: conference.id, commercialable_id: 'Conference') - unless conference.media_id.blank? || conference.media_type.blank? - TempCommercial.create(commercial_id: conference.media_id, - commercial_type: conference.media_type, - commercialable_id: conference.id, - commercialable_type: 'Conference') - end - end + next if TempCommercial.exists?(commercialable_id: conference.id, commercialable_id: 'Conference') + next if conference.media_id.blank? || conference.media_type.blank? + TempCommercial.create(commercial_id: conference.media_id, + commercial_type: conference.media_type, + commercialable_id: conference.id, + commercialable_type: 'Conference') end # Then remove all the columns diff --git a/db/migrate/20140801170430_move_event_media_to_commercial.rb b/db/migrate/20140801170430_move_event_media_to_commercial.rb index b4fdc16f..0093c4b3 100644 --- a/db/migrate/20140801170430_move_event_media_to_commercial.rb +++ b/db/migrate/20140801170430_move_event_media_to_commercial.rb @@ -1,23 +1,23 @@ +# frozen_string_literal: true + class MoveEventMediaToCommercial < ActiveRecord::Migration - class TempEvent < ActiveRecord::Base + class TempEvent < ApplicationRecord self.table_name = 'events' end - class TempCommercial < ActiveRecord::Base + class TempCommercial < ApplicationRecord self.table_name = 'commercials' end def change # Move all the settings to the new object TempEvent.all.each do |event| - unless TempCommercial.exists?(commercialable_id: event.id, commercialable_id: 'Conference') - unless event.media_id.blank? || event.media_type.blank? - TempCommercial.create(commercial_id: event.media_id, - commercial_type: event.media_type, - commercialable_id: event.id, - commercialable_type: 'Event') - end - end + next if TempCommercial.exists?(commercialable_id: event.id, commercialable_id: 'Conference') + next if event.media_id.blank? || event.media_type.blank? + TempCommercial.create(commercial_id: event.media_id, + commercial_type: event.media_type, + commercialable_id: event.id, + commercialable_type: 'Event') end # Then remove all the columns diff --git a/db/migrate/20140804185823_create_registration_periods.rb b/db/migrate/20140804185823_create_registration_periods.rb index 4906144a..e8814623 100644 --- a/db/migrate/20140804185823_create_registration_periods.rb +++ b/db/migrate/20140804185823_create_registration_periods.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateRegistrationPeriods < ActiveRecord::Migration def up create_table :registration_periods do |t| diff --git a/db/migrate/20140812065531_move_conference_registration_data_to_registration_periods.rb b/db/migrate/20140812065531_move_conference_registration_data_to_registration_periods.rb index 7d86ae75..7bac1ece 100644 --- a/db/migrate/20140812065531_move_conference_registration_data_to_registration_periods.rb +++ b/db/migrate/20140812065531_move_conference_registration_data_to_registration_periods.rb @@ -1,21 +1,22 @@ +# frozen_string_literal: true + class MoveConferenceRegistrationDataToRegistrationPeriods < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' end - class TempRegistrationPeriod < ActiveRecord::Base + class TempRegistrationPeriod < ApplicationRecord self.table_name = 'registration_periods' end def up # Move all the settings to the new object TempConference.all.each do |conference| - unless TempRegistrationPeriod.exists?(conference_id: conference.id) - TempRegistrationPeriod.create(conference_id: conference.id, - start_date: conference.registration_start_date, - end_date: conference.registration_end_date, - description: conference.registration_description) - end + next if TempRegistrationPeriod.exists?(conference_id: conference.id) + TempRegistrationPeriod.create(conference_id: conference.id, + start_date: conference.registration_start_date, + end_date: conference.registration_end_date, + description: conference.registration_description) end # Remove Columns diff --git a/db/migrate/20140819124315_rename_supporter_level_to_ticket.rb b/db/migrate/20140819124315_rename_supporter_level_to_ticket.rb index 38fb10b6..c88ccba5 100644 --- a/db/migrate/20140819124315_rename_supporter_level_to_ticket.rb +++ b/db/migrate/20140819124315_rename_supporter_level_to_ticket.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameSupporterLevelToTicket < ActiveRecord::Migration def up rename_table :supporter_levels, :tickets diff --git a/db/migrate/20140820093735_migrating_supporter_registrations_to_ticket_users.rb b/db/migrate/20140820093735_migrating_supporter_registrations_to_ticket_users.rb index 8be20de2..6baf22f2 100644 --- a/db/migrate/20140820093735_migrating_supporter_registrations_to_ticket_users.rb +++ b/db/migrate/20140820093735_migrating_supporter_registrations_to_ticket_users.rb @@ -1,13 +1,15 @@ +# frozen_string_literal: true + class MigratingSupporterRegistrationsToTicketUsers < ActiveRecord::Migration - class TempSupporterRegistrations < ActiveRecord::Base + class TempSupporterRegistrations < ApplicationRecord self.table_name = 'supporter_registrations' end - class TempUser < ActiveRecord::Base + class TempUser < ApplicationRecord self.table_name = 'users' end - class TempRegistration < ActiveRecord::Base + class TempRegistration < ApplicationRecord self.table_name = 'registrations' end @@ -39,20 +41,20 @@ class MigratingSupporterRegistrationsToTicketUsers < ActiveRecord::Migration # Sum up if a user has bought more than one ticket TempSupporterRegistrations.all.each do |s| sup_reg = TempSupporterRegistrations.where( - ticket_id: s.ticket_id, - user_id: s.user_id, - conference_id: s.conference_id) + ticket_id: s.ticket_id, + user_id: s.user_id, + conference_id: s.conference_id + ) quantity = sup_reg.count - if quantity > 1 - # Save the amount in the first one - s.quantity = quantity - s.save + next unless quantity > 1 + # Save the amount in the first one + s.quantity = quantity + s.save - # Delete the other - sup_reg = sup_reg.where('id not in (?)', [s.id]) - sup_reg.destroy_all - end + # Delete the other + sup_reg = sup_reg.where('id not in (?)', [s.id]) + sup_reg.destroy_all end remove_column :supporter_registrations, :registration_id diff --git a/db/migrate/20140820123503_assign_users_to_events.rb b/db/migrate/20140820123503_assign_users_to_events.rb index dc0334a7..4473c6e5 100644 --- a/db/migrate/20140820123503_assign_users_to_events.rb +++ b/db/migrate/20140820123503_assign_users_to_events.rb @@ -1,13 +1,15 @@ +# frozen_string_literal: true + class AssignUsersToEvents < ActiveRecord::Migration - class TempEvent < ActiveRecord::Base + class TempEvent < ApplicationRecord self.table_name = 'events' end - class TempUser < ActiveRecord::Base + class TempUser < ApplicationRecord self.table_name = 'users' end - class TempEventUser < ActiveRecord::Base + class TempEventUser < ApplicationRecord self.table_name = 'event_users' belongs_to :temp_event belongs_to :temp_user @@ -37,6 +39,6 @@ class AssignUsersToEvents < ActiveRecord::Migration end def down - raise ActiveRecord::IrreversibleMigration.new('Cannot reverse migration.') + raise ActiveRecord::IrreversibleMigration, 'Cannot reverse migration.' end end diff --git a/db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb b/db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb index 60b77df2..1f8733aa 100644 --- a/db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb +++ b/db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb @@ -1,35 +1,33 @@ +# frozen_string_literal: true + class UndoWrongMigration20140801080705AddUsersToEvents < ActiveRecord::Migration - class TempEvent < ActiveRecord::Base + class TempEvent < ApplicationRecord self.table_name = 'events' end - class TempUser < ActiveRecord::Base + class TempUser < ApplicationRecord self.table_name = 'users' end - class TempEventUser < ActiveRecord::Base + class TempEventUser < ApplicationRecord self.table_name = 'event_users' belongs_to :temp_event belongs_to :temp_user end - class Version < ActiveRecord::Base + class Version < ApplicationRecord self.table_name = 'versions' end def up - if ActiveRecord::Migrator.get_all_versions.include? 20140801080705 + if ActiveRecord::Migrator.get_all_versions.include? 20_140_801_080_705 user_deleted = TempUser.find_by(email: 'deleted@localhost.osem') TempEvent.all.each do |event| whodunnit = Version.find_by(item_type: 'Event', item_id: event.id, event: 'create').whodunnit original_user = TempUser.find_by(id: whodunnit) - if original_user.blank? - original_submitter = user_deleted - else - original_submitter = original_user - end + original_submitter = original_user.presence || user_deleted # Substitute submitter record submitter = TempEventUser.find_by(event_id: event.id, event_role: 'submitter') @@ -45,6 +43,6 @@ class UndoWrongMigration20140801080705AddUsersToEvents < ActiveRecord::Migration end def down - raise ActiveRecord::IrreversibleMigration.new('Cannot reverse migration.') + raise ActiveRecord::IrreversibleMigration, 'Cannot reverse migration.' end end diff --git a/db/migrate/20140821103643_split_ticket_price_in_price_and_currency.rb b/db/migrate/20140821103643_split_ticket_price_in_price_and_currency.rb index 0dbf1045..4afa8603 100644 --- a/db/migrate/20140821103643_split_ticket_price_in_price_and_currency.rb +++ b/db/migrate/20140821103643_split_ticket_price_in_price_and_currency.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class SplitTicketPriceInPriceAndCurrency < ActiveRecord::Migration - class TempTicket < ActiveRecord::Base + class TempTicket < ApplicationRecord self.table_name = 'tickets' end @@ -8,18 +10,17 @@ class SplitTicketPriceInPriceAndCurrency < ActiveRecord::Migration TempTicket.all.each do |ticket| # Replace currency symbol with ISO Code - if ticket.ticket_price - ticket.ticket_price.gsub!('€', 'EUR') - ticket.ticket_price.gsub!('$', 'USD') - ticket.ticket_price.gsub!('£', 'GBP') - ticket.ticket_price.gsub!('¥', 'CNY') - ticket.ticket_price.gsub!('₹', 'INR') + next unless ticket.ticket_price + ticket.ticket_price.gsub!('€', 'EUR') + ticket.ticket_price.gsub!('$', 'USD') + ticket.ticket_price.gsub!('£', 'GBP') + ticket.ticket_price.gsub!('¥', 'CNY') + ticket.ticket_price.gsub!('₹', 'INR') - money = ticket.ticket_price.to_money - ticket.price_cents = money.cents - ticket.price_currency = money.currency_as_string - ticket.save - end + money = ticket.ticket_price.to_money + ticket.price_cents = money.cents + ticket.price_currency = money.currency_as_string + ticket.save end remove_column :tickets, :ticket_price diff --git a/db/migrate/20140825091222_create_splashpages.rb b/db/migrate/20140825091222_create_splashpages.rb index 0c9ca9b6..4056d86c 100644 --- a/db/migrate/20140825091222_create_splashpages.rb +++ b/db/migrate/20140825091222_create_splashpages.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateSplashpages < ActiveRecord::Migration def change create_table :splashpages do |t| diff --git a/db/migrate/20140825093132_move_splashpage_attributes_from_conference_to_splashpage.rb b/db/migrate/20140825093132_move_splashpage_attributes_from_conference_to_splashpage.rb index 222fa20b..c229934b 100644 --- a/db/migrate/20140825093132_move_splashpage_attributes_from_conference_to_splashpage.rb +++ b/db/migrate/20140825093132_move_splashpage_attributes_from_conference_to_splashpage.rb @@ -1,64 +1,64 @@ +# frozen_string_literal: true + class MoveSplashpageAttributesFromConferenceToSplashpage < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' end - class TempRegistrationPeriod < ActiveRecord::Base + class TempRegistrationPeriod < ApplicationRecord self.table_name = 'registration_periods' end - class TempContact < ActiveRecord::Base + class TempContact < ApplicationRecord self.table_name = 'contacts' end - class TempVenue < ActiveRecord::Base + class TempVenue < ApplicationRecord self.table_name = 'venues' end - class TempSplashpage < ActiveRecord::Base + class TempSplashpage < ApplicationRecord self.table_name = 'splashpages' end def change # Copy values to splashpage TempConference.all.each do |conference| - unless TempSplashpage.exists?(conference_id: conference.id) - splash = TempSplashpage.create(conference_id: conference.id, - public: conference.make_conference_public, - include_registrations: conference.include_registrations_in_splash, - include_tracks: conference.include_tracks_in_splash, - include_program: conference.include_program_in_splash, - include_banner: conference.include_banner_in_splash, - include_tickets: conference.include_tickets_in_splash, - ticket_description: conference.ticket_description, - include_sponsors: conference.include_sponsors_in_splash, - sponsor_description: conference.sponsor_description, - lodging_description: conference.lodging_description, - banner_description: conference.description, - banner_photo_file_name: conference.banner_photo_file_name, - banner_photo_content_type: conference.banner_photo_content_type, - banner_photo_file_size: conference.banner_photo_file_size, - banner_photo_updated_at: conference.banner_photo_updated_at) + next if TempSplashpage.exists?(conference_id: conference.id) + splash = TempSplashpage.create(conference_id: conference.id, + public: conference.make_conference_public, + include_registrations: conference.include_registrations_in_splash, + include_tracks: conference.include_tracks_in_splash, + include_program: conference.include_program_in_splash, + include_banner: conference.include_banner_in_splash, + include_tickets: conference.include_tickets_in_splash, + ticket_description: conference.ticket_description, + include_sponsors: conference.include_sponsors_in_splash, + sponsor_description: conference.sponsor_description, + lodging_description: conference.lodging_description, + banner_description: conference.description, + banner_photo_file_name: conference.banner_photo_file_name, + banner_photo_content_type: conference.banner_photo_content_type, + banner_photo_file_size: conference.banner_photo_file_size, + banner_photo_updated_at: conference.banner_photo_updated_at) - contact = TempContact.find_by(conference_id: conference.id) - if contact - splash.include_social_media = contact.public - splash.save - end - - registration = TempRegistrationPeriod.find_by(conference_id: conference.id) - if registration - splash.registration_description = registration.description - splash.save - end - - venue = TempVenue.find_by(id: conference.venue_id) - if venue - splash.include_lodgings = venue.include_lodgings_in_splash - splash.include_venue = venue.include_venue_in_splash - splash.save - end + contact = TempContact.find_by(conference_id: conference.id) + if contact + splash.include_social_media = contact.public + splash.save end + + registration = TempRegistrationPeriod.find_by(conference_id: conference.id) + if registration + splash.registration_description = registration.description + splash.save + end + + venue = TempVenue.find_by(id: conference.venue_id) + next unless venue + splash.include_lodgings = venue.include_lodgings_in_splash + splash.include_venue = venue.include_venue_in_splash + splash.save end # Remove columns diff --git a/db/migrate/20140930092923_move_sponsor_email_to_contact.rb b/db/migrate/20140930092923_move_sponsor_email_to_contact.rb index 2fe5f47a..cff288d5 100644 --- a/db/migrate/20140930092923_move_sponsor_email_to_contact.rb +++ b/db/migrate/20140930092923_move_sponsor_email_to_contact.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + class MoveSponsorEmailToContact < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' end - class TempContact < ActiveRecord::Base + class TempContact < ApplicationRecord self.table_name = 'contacts' end diff --git a/db/migrate/20141031225545_add_require_handicapped_access_to_questions.rb b/db/migrate/20141031225545_add_require_handicapped_access_to_questions.rb index ad2328c9..335db82e 100644 --- a/db/migrate/20141031225545_add_require_handicapped_access_to_questions.rb +++ b/db/migrate/20141031225545_add_require_handicapped_access_to_questions.rb @@ -1,24 +1,26 @@ +# frozen_string_literal: true + class AddRequireHandicappedAccessToQuestions < ActiveRecord::Migration - class TempRegistration < ActiveRecord::Base + class TempRegistration < ApplicationRecord self.table_name = 'registrations' belongs_to :temp_conference end - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' has_many :temp_registrations has_many :temp_questions end - class TempQuestionType < ActiveRecord::Base + class TempQuestionType < ApplicationRecord self.table_name = 'question_types' has_many :temp_questions end - class TempQuestion < ActiveRecord::Base + class TempQuestion < ApplicationRecord self.table_name = 'questions' has_many :temp_qanswers @@ -27,25 +29,25 @@ class AddRequireHandicappedAccessToQuestions < ActiveRecord::Migration has_and_belongs_to_many :temp_conferences end - class TempAnswer < ActiveRecord::Base + class TempAnswer < ApplicationRecord self.table_name = 'answers' has_many :temp_qanswers has_many :temp_questions, through: :temp_qanswers end - class TempQanswer < ActiveRecord::Base + class TempQanswer < ApplicationRecord self.table_name = 'qanswers' belongs_to :temp_question belongs_to :temp_answer end - class TempConferencesQuestions < ActiveRecord::Base + class TempConferencesQuestions < ApplicationRecord self.table_name = 'conferences_questions' end - class TempQanswerRegistration < ActiveRecord::Base + class TempQanswerRegistration < ApplicationRecord self.table_name = 'qanswers_registrations' end diff --git a/db/migrate/20141031225606_add_attending_with_partner_to_questions.rb b/db/migrate/20141031225606_add_attending_with_partner_to_questions.rb index 0a63a380..2451fbcb 100644 --- a/db/migrate/20141031225606_add_attending_with_partner_to_questions.rb +++ b/db/migrate/20141031225606_add_attending_with_partner_to_questions.rb @@ -1,24 +1,26 @@ +# frozen_string_literal: true + class AddAttendingWithPartnerToQuestions < ActiveRecord::Migration - class TempRegistration < ActiveRecord::Base + class TempRegistration < ApplicationRecord self.table_name = 'registrations' belongs_to :temp_conference end - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' has_many :temp_registrations has_many :temp_questions end - class TempQuestionType < ActiveRecord::Base + class TempQuestionType < ApplicationRecord self.table_name = 'question_types' has_many :temp_questions end - class TempQuestion < ActiveRecord::Base + class TempQuestion < ApplicationRecord self.table_name = 'questions' has_many :temp_qanswers @@ -27,25 +29,25 @@ class AddAttendingWithPartnerToQuestions < ActiveRecord::Migration has_and_belongs_to_many :temp_conferences end - class TempAnswer < ActiveRecord::Base + class TempAnswer < ApplicationRecord self.table_name = 'answers' has_many :temp_qanswers has_many :temp_questions, through: :temp_qanswers end - class TempQanswer < ActiveRecord::Base + class TempQanswer < ApplicationRecord self.table_name = 'qanswers' belongs_to :temp_question belongs_to :temp_answer end - class TempConferencesQuestions < ActiveRecord::Base + class TempConferencesQuestions < ApplicationRecord self.table_name = 'conferences_questions' end - class TempQanswerRegistration < ActiveRecord::Base + class TempQanswerRegistration < ApplicationRecord self.table_name = 'qanswers_registrations' end diff --git a/db/migrate/20141031225620_add_staying_at_suggested_hotel_to_questions.rb b/db/migrate/20141031225620_add_staying_at_suggested_hotel_to_questions.rb index fb0d8781..c4128a24 100644 --- a/db/migrate/20141031225620_add_staying_at_suggested_hotel_to_questions.rb +++ b/db/migrate/20141031225620_add_staying_at_suggested_hotel_to_questions.rb @@ -1,24 +1,26 @@ +# frozen_string_literal: true + class AddStayingAtSuggestedHotelToQuestions < ActiveRecord::Migration - class TempRegistration < ActiveRecord::Base + class TempRegistration < ApplicationRecord self.table_name = 'registrations' belongs_to :temp_conference end - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' has_many :temp_registrations has_many :temp_questions end - class TempQuestionType < ActiveRecord::Base + class TempQuestionType < ApplicationRecord self.table_name = 'question_types' has_many :temp_questions end - class TempQuestion < ActiveRecord::Base + class TempQuestion < ApplicationRecord self.table_name = 'questions' has_many :temp_qanswers @@ -27,25 +29,25 @@ class AddStayingAtSuggestedHotelToQuestions < ActiveRecord::Migration has_and_belongs_to_many :temp_conferences end - class TempAnswer < ActiveRecord::Base + class TempAnswer < ApplicationRecord self.table_name = 'answers' has_many :temp_qanswers has_many :temp_questions, through: :temp_qanswers end - class TempQanswer < ActiveRecord::Base + class TempQanswer < ApplicationRecord self.table_name = 'qanswers' belongs_to :temp_question belongs_to :temp_answer end - class TempConferencesQuestions < ActiveRecord::Base + class TempConferencesQuestions < ApplicationRecord self.table_name = 'conferences_questions' end - class TempQanswerRegistration < ActiveRecord::Base + class TempQanswerRegistration < ApplicationRecord self.table_name = 'qanswers_registrations' end diff --git a/db/migrate/20141031225635_add_attending_social_events_to_questions.rb b/db/migrate/20141031225635_add_attending_social_events_to_questions.rb index 54e3bb33..e85f73b1 100644 --- a/db/migrate/20141031225635_add_attending_social_events_to_questions.rb +++ b/db/migrate/20141031225635_add_attending_social_events_to_questions.rb @@ -1,24 +1,26 @@ +# frozen_string_literal: true + class AddAttendingSocialEventsToQuestions < ActiveRecord::Migration - class TempRegistration < ActiveRecord::Base + class TempRegistration < ApplicationRecord self.table_name = 'registrations' belongs_to :temp_conference end - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' has_many :temp_registrations has_many :temp_questions end - class TempQuestionType < ActiveRecord::Base + class TempQuestionType < ApplicationRecord self.table_name = 'question_types' has_many :temp_questions end - class TempQuestion < ActiveRecord::Base + class TempQuestion < ApplicationRecord self.table_name = 'questions' has_many :temp_qanswers @@ -27,25 +29,25 @@ class AddAttendingSocialEventsToQuestions < ActiveRecord::Migration has_and_belongs_to_many :temp_conferences end - class TempAnswer < ActiveRecord::Base + class TempAnswer < ApplicationRecord self.table_name = 'answers' has_many :temp_qanswers has_many :temp_questions, through: :temp_qanswers end - class TempQanswer < ActiveRecord::Base + class TempQanswer < ApplicationRecord self.table_name = 'qanswers' belongs_to :temp_question belongs_to :temp_answer end - class TempConferencesQuestions < ActiveRecord::Base + class TempConferencesQuestions < ApplicationRecord self.table_name = 'conferences_questions' end - class TempQanswerRegistration < ActiveRecord::Base + class TempQanswerRegistration < ApplicationRecord self.table_name = 'qanswers_registrations' end diff --git a/db/migrate/20141103132913_add_username_to_users.rb b/db/migrate/20141103132913_add_username_to_users.rb index 59cd8591..48b0573c 100644 --- a/db/migrate/20141103132913_add_username_to_users.rb +++ b/db/migrate/20141103132913_add_username_to_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddUsernameToUsers < ActiveRecord::Migration def change add_column :users, :username, :string diff --git a/db/migrate/20141104131625_generate_username.rb b/db/migrate/20141104131625_generate_username.rb index e1ddf111..0f1745de 100644 --- a/db/migrate/20141104131625_generate_username.rb +++ b/db/migrate/20141104131625_generate_username.rb @@ -1,15 +1,16 @@ +# frozen_string_literal: true + class GenerateUsername < ActiveRecord::Migration - class TempUser < ActiveRecord::Base + class TempUser < ApplicationRecord self.table_name = 'users' end def change TempUser.all.each do |user| - if user.username.blank? - username = user.email.split('@')[0] - username += user.id.to_s if TempUser.find_by(username: username) - user.update_attributes(username: username) - end + next if user.username.present? + username = user.email.split('@')[0] + username += user.id.to_s if TempUser.find_by(username: username) + user.update(username: username) end end end diff --git a/db/migrate/20141106141750_add_is_disabled_flag_to_user.rb b/db/migrate/20141106141750_add_is_disabled_flag_to_user.rb index 07830d74..6f3fa63c 100644 --- a/db/migrate/20141106141750_add_is_disabled_flag_to_user.rb +++ b/db/migrate/20141106141750_add_is_disabled_flag_to_user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddIsDisabledFlagToUser < ActiveRecord::Migration def change add_column :users, :is_disabled, :boolean, default: false diff --git a/db/migrate/20141109172204_set_room_public_default_to_false.rb b/db/migrate/20141109172204_set_room_public_default_to_false.rb index ae215bab..1b198154 100644 --- a/db/migrate/20141109172204_set_room_public_default_to_false.rb +++ b/db/migrate/20141109172204_set_room_public_default_to_false.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SetRoomPublicDefaultToFalse < ActiveRecord::Migration def change change_column :rooms, :public, :boolean, default: false diff --git a/db/migrate/20141113134103_add_position_to_sponsorship_level.rb b/db/migrate/20141113134103_add_position_to_sponsorship_level.rb index 5663d3e6..3683964d 100644 --- a/db/migrate/20141113134103_add_position_to_sponsorship_level.rb +++ b/db/migrate/20141113134103_add_position_to_sponsorship_level.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPositionToSponsorshipLevel < ActiveRecord::Migration def change add_column :sponsorship_levels, :position, :integer diff --git a/db/migrate/20141117214230_move_banner_description_to_conference.rb b/db/migrate/20141117214230_move_banner_description_to_conference.rb index 6073926f..ce3d7e8d 100644 --- a/db/migrate/20141117214230_move_banner_description_to_conference.rb +++ b/db/migrate/20141117214230_move_banner_description_to_conference.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + class MoveBannerDescriptionToConference < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' end - class TempSplashpage < ActiveRecord::Base + class TempSplashpage < ApplicationRecord self.table_name = 'splashpages' end @@ -15,7 +17,7 @@ class MoveBannerDescriptionToConference < ActiveRecord::Migration TempConference.all.each do |conference| if TempSplashpage.exists?(conference_id: conference.id) splash = TempSplashpage.find_by(conference_id: conference.id) - conference.update_attributes(description: splash.banner_description) + conference.update(description: splash.banner_description) end end diff --git a/db/migrate/20141117222919_drop_splash_descriptions_and_photo.rb b/db/migrate/20141117222919_drop_splash_descriptions_and_photo.rb index 343ea467..e4701a12 100644 --- a/db/migrate/20141117222919_drop_splash_descriptions_and_photo.rb +++ b/db/migrate/20141117222919_drop_splash_descriptions_and_photo.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DropSplashDescriptionsAndPhoto < ActiveRecord::Migration def change remove_column :splashpages, :ticket_description diff --git a/db/migrate/20141118143700_add_address_fields_to_venue.rb b/db/migrate/20141118143700_add_address_fields_to_venue.rb index 01df5d9b..c91d6033 100644 --- a/db/migrate/20141118143700_add_address_fields_to_venue.rb +++ b/db/migrate/20141118143700_add_address_fields_to_venue.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddAddressFieldsToVenue < ActiveRecord::Migration def change add_column :venues, :street, :string diff --git a/db/migrate/20141118150427_cleanup_venue.rb b/db/migrate/20141118150427_cleanup_venue.rb index b985c676..31cb86fd 100644 --- a/db/migrate/20141118150427_cleanup_venue.rb +++ b/db/migrate/20141118150427_cleanup_venue.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CleanupVenue < ActiveRecord::Migration def change change_column :venues, :name, :string diff --git a/db/migrate/20141118153918_change_venue_conference_association.rb b/db/migrate/20141118153918_change_venue_conference_association.rb index 810179e5..773c254c 100644 --- a/db/migrate/20141118153918_change_venue_conference_association.rb +++ b/db/migrate/20141118153918_change_venue_conference_association.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + class ChangeVenueConferenceAssociation < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' end - class TempVenue < ActiveRecord::Base + class TempVenue < ApplicationRecord self.table_name = 'venues' end @@ -15,7 +17,7 @@ class ChangeVenueConferenceAssociation < ActiveRecord::Migration TempConference.all.each do |conference| if TempVenue.exists?(id: conference.venue_id) venue = TempVenue.find_by(id: conference.venue_id) - venue.update_attributes(conference_id: conference.id) + venue.update(conference_id: conference.id) end end diff --git a/db/migrate/20141118162030_change_lodging_association_to_conference.rb b/db/migrate/20141118162030_change_lodging_association_to_conference.rb index 352075ec..3e476d3e 100644 --- a/db/migrate/20141118162030_change_lodging_association_to_conference.rb +++ b/db/migrate/20141118162030_change_lodging_association_to_conference.rb @@ -1,13 +1,15 @@ +# frozen_string_literal: true + class ChangeLodgingAssociationToConference < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' end - class TempVenue < ActiveRecord::Base + class TempVenue < ApplicationRecord self.table_name = 'venues' end - class TempLodging < ActiveRecord::Base + class TempLodging < ApplicationRecord self.table_name = 'lodgings' end @@ -17,12 +19,11 @@ class ChangeLodgingAssociationToConference < ActiveRecord::Migration # Change association from venue and conference TempConference.all.each do |conference| - if TempVenue.exists?(conference_id: conference.id) - venue = TempVenue.find_by(conference_id: conference.id) - lodgings = TempLodging.where(venue_id: venue.id) - lodgings.each do |lodging| - lodging.update_attributes(conference_id: conference.id) - end + next unless TempVenue.exists?(conference_id: conference.id) + venue = TempVenue.find_by(conference_id: conference.id) + lodgings = TempLodging.where(venue_id: venue.id) + lodgings.each do |lodging| + lodging.update(conference_id: conference.id) end end diff --git a/db/migrate/20141120205757_remove_public_from_room.rb b/db/migrate/20141120205757_remove_public_from_room.rb index fa44e5ac..f96aa84c 100644 --- a/db/migrate/20141120205757_remove_public_from_room.rb +++ b/db/migrate/20141120205757_remove_public_from_room.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemovePublicFromRoom < ActiveRecord::Migration def change remove_column :rooms, :public, :boolean, default: false diff --git a/db/migrate/20141121102656_remove_description_from_call_for_paper.rb b/db/migrate/20141121102656_remove_description_from_call_for_paper.rb index 89e8cdbb..fc6282a5 100644 --- a/db/migrate/20141121102656_remove_description_from_call_for_paper.rb +++ b/db/migrate/20141121102656_remove_description_from_call_for_paper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveDescriptionFromCallForPaper < ActiveRecord::Migration def change remove_column :call_for_papers, :description, :text diff --git a/db/migrate/20141127161313_add_is_highlight_in_events.rb b/db/migrate/20141127161313_add_is_highlight_in_events.rb index 0b61ef26..694e0ea2 100644 --- a/db/migrate/20141127161313_add_is_highlight_in_events.rb +++ b/db/migrate/20141127161313_add_is_highlight_in_events.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddIsHighlightInEvents < ActiveRecord::Migration def change add_column :events, :is_highlight, :boolean, default: false diff --git a/db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb b/db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb index 2f794f75..9eb23d78 100644 --- a/db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb +++ b/db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb @@ -1,13 +1,15 @@ +# frozen_string_literal: true + class MigrateDataRemoveColumnIncludeCfpInSplashAddColumnIncludeCfp < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' end - class TempCallForPaper < ActiveRecord::Base + class TempCallForPaper < ApplicationRecord self.table_name = 'call_for_papers' end - class TempSplashpage < ActiveRecord::Base + class TempSplashpage < ApplicationRecord self.table_name = 'splashpages' end @@ -17,11 +19,10 @@ class MigrateDataRemoveColumnIncludeCfpInSplashAddColumnIncludeCfp < ActiveRecor TempConference.all.each do |conference| cfp = TempCallForPaper.find_by(conference_id: conference.id) - if cfp && cfp.include_cfp_in_splash - splashpage = TempSplashpage.find_or_initialize_by(conference_id: conference.id) - splashpage.include_cfp = cfp.include_cfp_in_splash # true - splashpage.save! - end + next unless cfp&.include_cfp_in_splash + splashpage = TempSplashpage.find_or_initialize_by(conference_id: conference.id) + splashpage.include_cfp = cfp.include_cfp_in_splash # true + splashpage.save! end remove_column :call_for_papers, :include_cfp_in_splash, :boolean, default: false diff --git a/db/migrate/20141130182139_drop_table_event_attachments.rb b/db/migrate/20141130182139_drop_table_event_attachments.rb index 76f2d72e..dbe856c1 100644 --- a/db/migrate/20141130182139_drop_table_event_attachments.rb +++ b/db/migrate/20141130182139_drop_table_event_attachments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DropTableEventAttachments < ActiveRecord::Migration def change drop_table :event_attachments diff --git a/db/migrate/20150304135935_add_created_atto_qanswer.rb b/db/migrate/20150304135935_add_created_atto_qanswer.rb index a0a2f4cf..e4a319e2 100644 --- a/db/migrate/20150304135935_add_created_atto_qanswer.rb +++ b/db/migrate/20150304135935_add_created_atto_qanswer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCreatedAttoQanswer < ActiveRecord::Migration def change add_column :qanswers, :created_at, :datetime diff --git a/db/migrate/20150415121038_add_description_to_event_type.rb b/db/migrate/20150415121038_add_description_to_event_type.rb index fa688c02..3979d574 100644 --- a/db/migrate/20150415121038_add_description_to_event_type.rb +++ b/db/migrate/20150415121038_add_description_to_event_type.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDescriptionToEventType < ActiveRecord::Migration def change add_column :event_types, :description, :string diff --git a/db/migrate/20150417050953_add_url_to_commercial.rb b/db/migrate/20150417050953_add_url_to_commercial.rb index 56adf34f..46bf73fb 100644 --- a/db/migrate/20150417050953_add_url_to_commercial.rb +++ b/db/migrate/20150417050953_add_url_to_commercial.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class AddUrlToCommercial < ActiveRecord::Migration - class TempCommercial < ActiveRecord::Base + class TempCommercial < ApplicationRecord self.table_name = 'commercials' end diff --git a/db/migrate/20150929142405_change_postalcode_format_in_venues.rb b/db/migrate/20150929142405_change_postalcode_format_in_venues.rb index 010f9349..93fdf50f 100644 --- a/db/migrate/20150929142405_change_postalcode_format_in_venues.rb +++ b/db/migrate/20150929142405_change_postalcode_format_in_venues.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + class ChangePostalcodeFormatInVenues < ActiveRecord::Migration def up change_column :venues, :postalcode, :string end def down - raise ActiveRecord::IrreversibleMigration.new('Cannot reverse migration.') + raise ActiveRecord::IrreversibleMigration, 'Cannot reverse migration.' end end diff --git a/db/migrate/20151005161518_rename_templates_in_email_settings.rb b/db/migrate/20151005161518_rename_templates_in_email_settings.rb index 8cb3ad49..848cd9a3 100644 --- a/db/migrate/20151005161518_rename_templates_in_email_settings.rb +++ b/db/migrate/20151005161518_rename_templates_in_email_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameTemplatesInEmailSettings < ActiveRecord::Migration def change rename_column :email_settings, :registration_email_template, :registration_body diff --git a/db/migrate/20151018152439_create_programs_table.rb b/db/migrate/20151018152439_create_programs_table.rb index 4a71edb4..5f61292b 100644 --- a/db/migrate/20151018152439_create_programs_table.rb +++ b/db/migrate/20151018152439_create_programs_table.rb @@ -1,17 +1,19 @@ +# frozen_string_literal: true + class CreateProgramsTable < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' end - class TempCfp < ActiveRecord::Base + class TempCfp < ApplicationRecord self.table_name = 'cfps' end - class TempCallForPaper < ActiveRecord::Base + class TempCallForPaper < ApplicationRecord self.table_name = 'call_for_papers' end - class TempProgram < ActiveRecord::Base + class TempProgram < ApplicationRecord self.table_name = 'programs' end @@ -27,21 +29,19 @@ class CreateProgramsTable < ActiveRecord::Migration add_column :call_for_papers, :program_id, :integer TempConference.all.each do |conference| - unless TempProgram.find_by(conference_id: conference.id) - program = TempProgram.new - program.conference_id = conference.id - program.save! + next if TempProgram.find_by(conference_id: conference.id) + program = TempProgram.new + program.conference_id = conference.id + program.save! - if (cfp = TempCallForPaper.find_by(conference_id: conference.id)) - cfp.program_id = program.id - cfp.save! + next unless (cfp = TempCallForPaper.find_by(conference_id: conference.id)) + cfp.program_id = program.id + cfp.save! - program.rating = cfp.rating - program.schedule_public = cfp.schedule_public - program.schedule_fluid = cfp.schedule_changes - program.save! - end - end + program.rating = cfp.rating + program.schedule_public = cfp.schedule_public + program.schedule_fluid = cfp.schedule_changes + program.save! end remove_column :call_for_papers, :conference_id remove_column :call_for_papers, :rating @@ -58,16 +58,14 @@ class CreateProgramsTable < ActiveRecord::Migration add_column :call_for_papers, :schedule_changes, :boolean, default: false TempConference.all.each do |conference| - if (program = TempProgram.find_by(conference_id: conference.id)) - if (cfp = TempCallForPaper.find_by(program_id: program.id)) - cfp.conference_id = program.conference_id - cfp.rating = program.rating - cfp.schedule_public = program.schedule_public - cfp.schedule_changes = program.schedule_fluid + next unless (program = TempProgram.find_by(conference_id: conference.id)) + next unless (cfp = TempCallForPaper.find_by(program_id: program.id)) + cfp.conference_id = program.conference_id + cfp.rating = program.rating + cfp.schedule_public = program.schedule_public + cfp.schedule_changes = program.schedule_fluid - cfp.save! - end - end + cfp.save! end remove_column :call_for_papers, :program_id diff --git a/db/migrate/20151018154513_rename_conference_id_to_program_id_in_events_tracks_difficulty_levels.rb b/db/migrate/20151018154513_rename_conference_id_to_program_id_in_events_tracks_difficulty_levels.rb index b540b9a3..37190852 100644 --- a/db/migrate/20151018154513_rename_conference_id_to_program_id_in_events_tracks_difficulty_levels.rb +++ b/db/migrate/20151018154513_rename_conference_id_to_program_id_in_events_tracks_difficulty_levels.rb @@ -1,25 +1,27 @@ +# frozen_string_literal: true + class RenameConferenceIdToProgramIdInEventsTracksDifficultyLevels < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' end - class TempEvent < ActiveRecord::Base + class TempEvent < ApplicationRecord self.table_name = 'events' end - class TempEventType < ActiveRecord::Base + class TempEventType < ApplicationRecord self.table_name = 'event_types' end - class TempTrack < ActiveRecord::Base + class TempTrack < ApplicationRecord self.table_name = 'tracks' end - class TempDifficultyLevel < ActiveRecord::Base + class TempDifficultyLevel < ApplicationRecord self.table_name = 'difficulty_levels' end - class TempProgram < ActiveRecord::Base + class TempProgram < ApplicationRecord self.table_name = 'programs' end @@ -68,26 +70,25 @@ class RenameConferenceIdToProgramIdInEventsTracksDifficultyLevels < ActiveRecord TempConference.all.each do |conference| program = TempProgram.find_by(conference_id: conference.id) - if program - TempEvent.where(program_id: program.id).each do |event| - event.conference_id = conference.id - event.save! - end + next unless program + TempEvent.where(program_id: program.id).each do |event| + event.conference_id = conference.id + event.save! + end - TempEventType.where(program_id: program.id).each do |event_type| - event_type.conference_id = conference.id - event_type.save! - end + TempEventType.where(program_id: program.id).each do |event_type| + event_type.conference_id = conference.id + event_type.save! + end - TempTrack.where(program_id: program.id).each do |track| - track.conference_id = conference.id - track.save! - end + TempTrack.where(program_id: program.id).each do |track| + track.conference_id = conference.id + track.save! + end - TempDifficultyLevel.where(program_id: program.id).each do |difficulty_level| - difficulty_level.conference_id = conference.id - difficulty_level.save! - end + TempDifficultyLevel.where(program_id: program.id).each do |difficulty_level| + difficulty_level.conference_id = conference.id + difficulty_level.save! end end diff --git a/db/migrate/20151021113015_rename_email_settings_with_cfp_and_program.rb b/db/migrate/20151021113015_rename_email_settings_with_cfp_and_program.rb index ca2978ca..b43c6c23 100644 --- a/db/migrate/20151021113015_rename_email_settings_with_cfp_and_program.rb +++ b/db/migrate/20151021113015_rename_email_settings_with_cfp_and_program.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameEmailSettingsWithCfpAndProgram < ActiveRecord::Migration def change rename_column :email_settings, :send_on_call_for_papers_schedule_public, :send_on_program_schedule_public diff --git a/db/migrate/20151031092713_change_conference_id_to_venue_id_in_rooms.rb b/db/migrate/20151031092713_change_conference_id_to_venue_id_in_rooms.rb index ca8ef153..b2f28567 100644 --- a/db/migrate/20151031092713_change_conference_id_to_venue_id_in_rooms.rb +++ b/db/migrate/20151031092713_change_conference_id_to_venue_id_in_rooms.rb @@ -1,18 +1,20 @@ +# frozen_string_literal: true + class ChangeConferenceIdToVenueIdInRooms < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' has_one :temp_venue end - class TempVenue < ActiveRecord::Base + class TempVenue < ApplicationRecord self.table_name = 'venues' belongs_to :temp_conference has_many :temp_rooms end - class TempRoom < ActiveRecord::Base + class TempRoom < ApplicationRecord self.table_name = 'rooms' belongs_to :temp_venue @@ -43,9 +45,7 @@ class ChangeConferenceIdToVenueIdInRooms < ActiveRecord::Migration venue = TempVenue.find(room.venue_id) conference = TempConference.find(venue.conference_id) - if conference - room.conference_id = conference.id - end + room.conference_id = conference.id if conference room.save! end diff --git a/db/migrate/20160201221411_add_registration_limit_to_conferences.rb b/db/migrate/20160201221411_add_registration_limit_to_conferences.rb index bbc8724e..82aa4df7 100644 --- a/db/migrate/20160201221411_add_registration_limit_to_conferences.rb +++ b/db/migrate/20160201221411_add_registration_limit_to_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRegistrationLimitToConferences < ActiveRecord::Migration def change add_column :conferences, :registration_limit, :integer, default: 0 diff --git a/db/migrate/20160226133808_rename_roles_users_to_users_roles.rb b/db/migrate/20160226133808_rename_roles_users_to_users_roles.rb index 6f8424b8..ca8af270 100644 --- a/db/migrate/20160226133808_rename_roles_users_to_users_roles.rb +++ b/db/migrate/20160226133808_rename_roles_users_to_users_roles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameRolesUsersToUsersRoles < ActiveRecord::Migration def change rename_table :roles_users, :users_roles diff --git a/db/migrate/20160309182642_remove_social_events_table.rb b/db/migrate/20160309182642_remove_social_events_table.rb index e44a7c3f..740203f1 100644 --- a/db/migrate/20160309182642_remove_social_events_table.rb +++ b/db/migrate/20160309182642_remove_social_events_table.rb @@ -1,18 +1,20 @@ +# frozen_string_literal: true + class RemoveSocialEventsTable < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' has_many :temp_social_events end - class TempSocialEvent < ActiveRecord::Base + class TempSocialEvent < ApplicationRecord self.table_name = 'social_events' belongs_to :temp_conference has_and_belongs_to_many :temp_registrations end - class TempRegistration < ActiveRecord::Base + class TempRegistration < ApplicationRecord self.table_name = 'registrations' belongs_to :temp_conference @@ -20,20 +22,20 @@ class RemoveSocialEventsTable < ActiveRecord::Migration has_and_belongs_to_many :temp_qanswers end - class TempRegistrationsSocialEvent < ActiveRecord::Base + class TempRegistrationsSocialEvent < ApplicationRecord self.table_name = 'registrations_social_events' belongs_to :temp_registrations belongs_to :temp_social_events end - class TempQuestionType < ActiveRecord::Base + class TempQuestionType < ApplicationRecord self.table_name = 'question_types' has_many :temp_questions end - class TempQuestion < ActiveRecord::Base + class TempQuestion < ApplicationRecord self.table_name = 'questions' has_many :temp_qanswers @@ -42,14 +44,14 @@ class RemoveSocialEventsTable < ActiveRecord::Migration has_and_belongs_to_many :temp_conferences end - class TempAnswer < ActiveRecord::Base + class TempAnswer < ApplicationRecord self.table_name = 'answers' has_many :temp_qanswers has_many :temp_questions, through: :temp_qanswers end - class TempQanswer < ActiveRecord::Base + class TempQanswer < ApplicationRecord self.table_name = 'qanswers' belongs_to :temp_question @@ -57,11 +59,11 @@ class RemoveSocialEventsTable < ActiveRecord::Migration has_and_belongs_to_many :temp_registrations end - class TempConferencesQuestions < ActiveRecord::Base + class TempConferencesQuestions < ApplicationRecord self.table_name = 'conferences_questions' end - class TempQanswerRegistration < ActiveRecord::Base + class TempQanswerRegistration < ApplicationRecord self.table_name = 'qanswers_registrations' end @@ -116,17 +118,16 @@ class RemoveSocialEventsTable < ActiveRecord::Migration qtype = TempQuestionType.find_by(title: 'Multiple Choice') TempConference.all.each do |conference| - if qtype && (question = TempQuestion.find_by(title: 'Which of the following social events are you going to attend?', - conference_id: conference.id, question_type_id: qtype.id)) - TempQanswer.where(question_id: question.id).each do |qa| - TempQanswerRegistration.where(qanswer_id: qa.id).each do |qa_registration| - answer = TempAnswer.find(qa.answer_id) - registration = TempRegistration.find(qa_registration.registration_id) - social_event = TempSocialEvent.find_or_create_by!(title: answer.title, - conference_id: conference.id) - TempRegistrationsSocialEvent.find_or_create_by!(registration_id: registration.id, - social_event_id: social_event.id) - end + next unless qtype && (question = TempQuestion.find_by(title: 'Which of the following social events are you going to attend?', + conference_id: conference.id, question_type_id: qtype.id)) + TempQanswer.where(question_id: question.id).each do |qa| + TempQanswerRegistration.where(qanswer_id: qa.id).each do |qa_registration| + answer = TempAnswer.find(qa.answer_id) + registration = TempRegistration.find(qa_registration.registration_id) + social_event = TempSocialEvent.find_or_create_by!(title: answer.title, + conference_id: conference.id) + TempRegistrationsSocialEvent.find_or_create_by!(registration_id: registration.id, + social_event_id: social_event.id) end end end diff --git a/db/migrate/20160309182655_remove_dietary_choices_table.rb b/db/migrate/20160309182655_remove_dietary_choices_table.rb index c61876bc..78f9580f 100644 --- a/db/migrate/20160309182655_remove_dietary_choices_table.rb +++ b/db/migrate/20160309182655_remove_dietary_choices_table.rb @@ -1,29 +1,31 @@ +# frozen_string_literal: true + class RemoveDietaryChoicesTable < ActiveRecord::Migration - class TempDietaryChoice < ActiveRecord::Base + class TempDietaryChoice < ApplicationRecord self.table_name = 'dietary_choices' belongs_to :temp_conference end - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' has_many :temp_dietary_choices, dependent: :destroy end - class TempRegistration < ActiveRecord::Base + class TempRegistration < ApplicationRecord self.table_name = 'registrations' belongs_to :temp_conference end - class TempQuestionType < ActiveRecord::Base + class TempQuestionType < ApplicationRecord self.table_name = 'question_types' has_many :temp_questions end - class TempQuestion < ActiveRecord::Base + class TempQuestion < ApplicationRecord self.table_name = 'questions' has_many :temp_qanswers @@ -32,14 +34,14 @@ class RemoveDietaryChoicesTable < ActiveRecord::Migration has_and_belongs_to_many :temp_conferences end - class TempAnswer < ActiveRecord::Base + class TempAnswer < ApplicationRecord self.table_name = 'answers' has_many :temp_qanswers has_many :temp_questions, through: :temp_qanswers end - class TempQanswer < ActiveRecord::Base + class TempQanswer < ApplicationRecord self.table_name = 'qanswers' belongs_to :temp_question @@ -47,78 +49,74 @@ class RemoveDietaryChoicesTable < ActiveRecord::Migration has_and_belongs_to_many :temp_registrations end - class TempConferencesQuestions < ActiveRecord::Base + class TempConferencesQuestions < ApplicationRecord self.table_name = 'conferences_questions' end - class TempQanswerRegistration < ActiveRecord::Base + class TempQanswerRegistration < ApplicationRecord self.table_name = 'qanswers_registrations' end def up # Create Question of 'Multiple Choice' type - if TempDietaryChoice.all.any? - qtype = TempQuestionType.find_or_create_by!(title: 'Single Choice') - end + qtype = TempQuestionType.find_or_create_by!(title: 'Single Choice') if TempDietaryChoice.all.any? # Migrate dietary_choice_id to a question TempConference.all.each do |conference| - if TempDietaryChoice.where(conference_id: conference.id).any? - # Find existing question or initialize it - question = TempQuestion.find_or_initialize_by(title: 'Which is your dietary choice?', - conference_id: conference.id, - question_type_id: qtype.id) - question.save! - # Enable the question for the conference - TempConferencesQuestions.find_or_create_by!(conference_id: conference.id, - question_id: question.id) + next unless TempDietaryChoice.where(conference_id: conference.id).any? + # Find existing question or initialize it + question = TempQuestion.find_or_initialize_by(title: 'Which is your dietary choice?', + conference_id: conference.id, + question_type_id: qtype.id) + question.save! + # Enable the question for the conference + TempConferencesQuestions.find_or_create_by!(conference_id: conference.id, + question_id: question.id) - TempDietaryChoice.where(conference_id: conference.id).each do |dietary_choice| - answer = TempAnswer.find_or_create_by!(title: dietary_choice.title) - # Associate answer with the question - qa = TempQanswer.find_or_initialize_by(question_id: question.id, - answer_id: answer.id) - qa.save! + TempDietaryChoice.where(conference_id: conference.id).each do |dietary_choice| + answer = TempAnswer.find_or_create_by!(title: dietary_choice.title) + # Associate answer with the question + qa = TempQanswer.find_or_initialize_by(question_id: question.id, + answer_id: answer.id) + qa.save! - # Associate appropriate answer with registration - TempRegistration.where(dietary_choice_id: dietary_choice.id).each do |registration| - TempQanswerRegistration.find_or_create_by!(registration_id: registration.id, - qanswer_id: qa.id) - end + # Associate appropriate answer with registration + TempRegistration.where(dietary_choice_id: dietary_choice.id).each do |registration| + TempQanswerRegistration.find_or_create_by!(registration_id: registration.id, + qanswer_id: qa.id) end end end # Migrate other_dietary_choice to a question and put data in other_special_needs TempRegistration.all.each do |registration| - if registration.other_dietary_choice.present? - conference = TempConference.find(registration.conference_id) - qtype = TempQuestionType.find_or_create_by!(title: 'Yes/No') - question = TempQuestion.find_or_initialize_by(title: 'Do you have another dietary choice?', - conference_id: conference.id, - question_type_id: qtype.id) - question.save! - # Enable the question for the conference - TempConferencesQuestions.find_or_create_by!(conference_id: conference.id, - question_id: question.id) + next if registration.other_dietary_choice.blank? + conference = TempConference.find(registration.conference_id) + qtype = TempQuestionType.find_or_create_by!(title: 'Yes/No') + question = TempQuestion.find_or_initialize_by(title: 'Do you have another dietary choice?', + conference_id: conference.id, + question_type_id: qtype.id) + question.save! + # Enable the question for the conference + TempConferencesQuestions.find_or_create_by!(conference_id: conference.id, + question_id: question.id) - # Create 'Yes' answer - answer_yes = TempAnswer.find_or_create_by!(title: 'Yes') + # Create 'Yes' answer + answer_yes = TempAnswer.find_or_create_by!(title: 'Yes') - # Associate answer with the question - qa = TempQanswer.find_or_initialize_by(question_id: question.id, - answer_id: answer_yes.id) + # Associate answer with the question + qa = TempQanswer.find_or_initialize_by(question_id: question.id, + answer_id: answer_yes.id) - qa.save! + qa.save! - # Associate appropriate answer with registration - TempQanswerRegistration.find_or_create_by!(registration_id: registration.id, - qanswer_id: qa.id) + # Associate appropriate answer with registration + TempQanswerRegistration.find_or_create_by!(registration_id: registration.id, + qanswer_id: qa.id) - # Move data from other_dietary_choice to other_special_needs - registration.other_special_needs << "Other dietary choice: #{registration.other_dietary_choice}." - registration.save! - end + # Move data from other_dietary_choice to other_special_needs + registration.other_special_needs << "Other dietary choice: #{registration.other_dietary_choice}." + registration.save! end remove_column :conferences, :use_dietary_choices @@ -140,17 +138,16 @@ class RemoveDietaryChoicesTable < ActiveRecord::Migration qtype = TempQuestionType.find_by(title: 'Single Choice') TempConference.all.each do |conference| - if qtype && (question = TempQuestion.find_by(title: 'Which is your dietary choice?', - conference_id: conference.id, question_type_id: qtype.id)) - TempQanswer.where(question_id: question.id).each do |qa| - TempQanswerRegistration.where(qanswer_id: qa.id).each do |qa_registration| - answer = TempAnswer.find(qa.answer_id) - registration = TempRegistration.find(qa_registration.registration_id) - dietary_choice = TempDietaryChoice.find_or_create_by!(title: answer.title, - conference_id: conference.id) - registration.dietary_choice_id = dietary_choice.id - registration.save! - end + next unless qtype && (question = TempQuestion.find_by(title: 'Which is your dietary choice?', + conference_id: conference.id, question_type_id: qtype.id)) + TempQanswer.where(question_id: question.id).each do |qa| + TempQanswerRegistration.where(qanswer_id: qa.id).each do |qa_registration| + answer = TempAnswer.find(qa.answer_id) + registration = TempRegistration.find(qa_registration.registration_id) + dietary_choice = TempDietaryChoice.find_or_create_by!(title: answer.title, + conference_id: conference.id) + registration.dietary_choice_id = dietary_choice.id + registration.save! end end end @@ -158,14 +155,13 @@ class RemoveDietaryChoicesTable < ActiveRecord::Migration qtype = TempQuestionType.find_by(title: 'Yes/No') answer_yes = TempAnswer.find_by(title: 'Yes') TempConference.all.each do |conference| - if qtype && (question = TempQuestion.find_by(title: 'Do you have another dietary choice?', - conference_id: conference.id, question_type_id: qtype.id)) - TempQanswer.where(question_id: question.id, answer_id: answer_yes.id).each do |qa| - TempQanswerRegistration.where(qanswer_id: qa.id).each do |qa_registration| - registration = TempRegistration.find(qa_registration.registration_id) - registration.other_dietary_choice = 'Yes' - registration.save! - end + next unless qtype && (question = TempQuestion.find_by(title: 'Do you have another dietary choice?', + conference_id: conference.id, question_type_id: qtype.id)) + TempQanswer.where(question_id: question.id, answer_id: answer_yes.id).each do |qa| + TempQanswerRegistration.where(qanswer_id: qa.id).each do |qa_registration| + registration = TempRegistration.find(qa_registration.registration_id) + registration.other_dietary_choice = 'Yes' + registration.save! end end end diff --git a/db/migrate/20160309183052_remove_html_export_path_from_conferences.rb b/db/migrate/20160309183052_remove_html_export_path_from_conferences.rb index f1d3171e..01fbd3a7 100644 --- a/db/migrate/20160309183052_remove_html_export_path_from_conferences.rb +++ b/db/migrate/20160309183052_remove_html_export_path_from_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveHtmlExportPathFromConferences < ActiveRecord::Migration def change remove_column :conferences, :html_export_path, :string diff --git a/db/migrate/20160320220630_add_languages_to_program.rb b/db/migrate/20160320220630_add_languages_to_program.rb index b49c01d1..49be193f 100644 --- a/db/migrate/20160320220630_add_languages_to_program.rb +++ b/db/migrate/20160320220630_add_languages_to_program.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddLanguagesToProgram < ActiveRecord::Migration def change add_column :programs, :languages, :string diff --git a/db/migrate/20160323154504_add_max_attendees_to_events.rb b/db/migrate/20160323154504_add_max_attendees_to_events.rb index a5a0d415..bb3e770f 100644 --- a/db/migrate/20160323154504_add_max_attendees_to_events.rb +++ b/db/migrate/20160323154504_add_max_attendees_to_events.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddMaxAttendeesToEvents < ActiveRecord::Migration def change add_column :events, :max_attendees, :integer diff --git a/db/migrate/20160326075326_add_attended_to_events_registrations.rb b/db/migrate/20160326075326_add_attended_to_events_registrations.rb index 2cbb6edc..562cdf34 100644 --- a/db/migrate/20160326075326_add_attended_to_events_registrations.rb +++ b/db/migrate/20160326075326_add_attended_to_events_registrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddAttendedToEventsRegistrations < ActiveRecord::Migration def change add_column :events_registrations, :attended, :boolean, default: false, null: false diff --git a/db/migrate/20160403214841_add_id_and_created_at_to_events_registrations.rb b/db/migrate/20160403214841_add_id_and_created_at_to_events_registrations.rb index 903ec851..6e1e7200 100644 --- a/db/migrate/20160403214841_add_id_and_created_at_to_events_registrations.rb +++ b/db/migrate/20160403214841_add_id_and_created_at_to_events_registrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddIdAndCreatedAtToEventsRegistrations < ActiveRecord::Migration def change add_column :events_registrations, :id, :primary_key diff --git a/db/migrate/20160427101444_remove_photos.rb b/db/migrate/20160427101444_remove_photos.rb index 966cf187..d1f93a63 100644 --- a/db/migrate/20160427101444_remove_photos.rb +++ b/db/migrate/20160427101444_remove_photos.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemovePhotos < ActiveRecord::Migration def change drop_table :photos do |t| diff --git a/db/migrate/20160427104236_add_pictures.rb b/db/migrate/20160427104236_add_pictures.rb index 5a56da9c..dcfa6a23 100644 --- a/db/migrate/20160427104236_add_pictures.rb +++ b/db/migrate/20160427104236_add_pictures.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPictures < ActiveRecord::Migration def change add_column :conferences, :picture, :string diff --git a/db/migrate/20160427104237_add_blind_voting_to_programs.rb b/db/migrate/20160427104237_add_blind_voting_to_programs.rb index 0313cf19..f92be56d 100644 --- a/db/migrate/20160427104237_add_blind_voting_to_programs.rb +++ b/db/migrate/20160427104237_add_blind_voting_to_programs.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddBlindVotingToPrograms < ActiveRecord::Migration def change add_column :programs, :blind_voting, :boolean, default: false diff --git a/db/migrate/20160427104238_add_voting_dates_to_program.rb b/db/migrate/20160427104238_add_voting_dates_to_program.rb index 9dcbf752..32c20714 100644 --- a/db/migrate/20160427104238_add_voting_dates_to_program.rb +++ b/db/migrate/20160427104238_add_voting_dates_to_program.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddVotingDatesToProgram < ActiveRecord::Migration def change add_column :programs, :voting_start_date, :datetime diff --git a/db/migrate/20160524050538_add_conference_id_to_versions.rb b/db/migrate/20160524050538_add_conference_id_to_versions.rb index 345218f1..e6c8a411 100644 --- a/db/migrate/20160524050538_add_conference_id_to_versions.rb +++ b/db/migrate/20160524050538_add_conference_id_to_versions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddConferenceIdToVersions < ActiveRecord::Migration def change add_column :versions, :conference_id, :integer diff --git a/db/migrate/20160524104006_remove_unused_logo_columns_and_use_difficulty_levels_from_conferences.rb b/db/migrate/20160524104006_remove_unused_logo_columns_and_use_difficulty_levels_from_conferences.rb index 77607c3f..fb3cedf6 100644 --- a/db/migrate/20160524104006_remove_unused_logo_columns_and_use_difficulty_levels_from_conferences.rb +++ b/db/migrate/20160524104006_remove_unused_logo_columns_and_use_difficulty_levels_from_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveUnusedLogoColumnsAndUseDifficultyLevelsFromConferences < ActiveRecord::Migration def up remove_column :conferences, :logo_updated_at diff --git a/db/migrate/20160524104501_remove_unused_logo_columns_from_sponsors.rb b/db/migrate/20160524104501_remove_unused_logo_columns_from_sponsors.rb index a1f0f4d5..1770d353 100644 --- a/db/migrate/20160524104501_remove_unused_logo_columns_from_sponsors.rb +++ b/db/migrate/20160524104501_remove_unused_logo_columns_from_sponsors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveUnusedLogoColumnsFromSponsors < ActiveRecord::Migration def up remove_column :sponsors, :logo_updated_at diff --git a/db/migrate/20160524104805_remove_logo_and_progress_and_time_slots_from_events.rb b/db/migrate/20160524104805_remove_logo_and_progress_and_time_slots_from_events.rb index f70926df..eccfffb2 100644 --- a/db/migrate/20160524104805_remove_logo_and_progress_and_time_slots_from_events.rb +++ b/db/migrate/20160524104805_remove_logo_and_progress_and_time_slots_from_events.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveLogoAndProgressAndTimeSlotsFromEvents < ActiveRecord::Migration def up remove_column :events, :logo_file_name diff --git a/db/migrate/20160606040848_create_payments.rb b/db/migrate/20160606040848_create_payments.rb index 6792ad02..6db6f4c2 100644 --- a/db/migrate/20160606040848_create_payments.rb +++ b/db/migrate/20160606040848_create_payments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreatePayments < ActiveRecord::Migration def change create_table :payments do |t| diff --git a/db/migrate/20160610073948_add_payment_id_to_ticket_purchases.rb b/db/migrate/20160610073948_add_payment_id_to_ticket_purchases.rb index 133a047b..3c3f5997 100644 --- a/db/migrate/20160610073948_add_payment_id_to_ticket_purchases.rb +++ b/db/migrate/20160610073948_add_payment_id_to_ticket_purchases.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPaymentIdToTicketPurchases < ActiveRecord::Migration def change add_column :ticket_purchases, :payment_id, :integer diff --git a/db/migrate/20160614145614_add_id_to_users_roles.rb b/db/migrate/20160614145614_add_id_to_users_roles.rb index 20153f96..59b8936a 100644 --- a/db/migrate/20160614145614_add_id_to_users_roles.rb +++ b/db/migrate/20160614145614_add_id_to_users_roles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddIdToUsersRoles < ActiveRecord::Migration def change add_column :users_roles, :id, :primary_key diff --git a/db/migrate/20160624151257_remove_unused_photo_columns_from_venues.rb b/db/migrate/20160624151257_remove_unused_photo_columns_from_venues.rb index 78d61171..c0e29eb1 100644 --- a/db/migrate/20160624151257_remove_unused_photo_columns_from_venues.rb +++ b/db/migrate/20160624151257_remove_unused_photo_columns_from_venues.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveUnusedPhotoColumnsFromVenues < ActiveRecord::Migration def up remove_column :venues, :photo_updated_at diff --git a/db/migrate/20160704091928_create_schedules.rb b/db/migrate/20160704091928_create_schedules.rb index 19370ab4..184046cc 100644 --- a/db/migrate/20160704091928_create_schedules.rb +++ b/db/migrate/20160704091928_create_schedules.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateSchedules < ActiveRecord::Migration def change create_table :schedules do |t| diff --git a/db/migrate/20160704092023_create_event_schedules.rb b/db/migrate/20160704092023_create_event_schedules.rb index 3762f7e2..8158b277 100644 --- a/db/migrate/20160704092023_create_event_schedules.rb +++ b/db/migrate/20160704092023_create_event_schedules.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateEventSchedules < ActiveRecord::Migration def change create_table :event_schedules do |t| diff --git a/db/migrate/20160815094215_add_times_to_conferences.rb b/db/migrate/20160815094215_add_times_to_conferences.rb index 758ed841..70630f01 100644 --- a/db/migrate/20160815094215_add_times_to_conferences.rb +++ b/db/migrate/20160815094215_add_times_to_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddTimesToConferences < ActiveRecord::Migration def change add_column :conferences, :start_hour, :integer, default: 9 diff --git a/db/migrate/20160815140302_add_index_to_event_schedule.rb b/db/migrate/20160815140302_add_index_to_event_schedule.rb index 51ee51d4..01dc017b 100644 --- a/db/migrate/20160815140302_add_index_to_event_schedule.rb +++ b/db/migrate/20160815140302_add_index_to_event_schedule.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class AddIndexToEventSchedule < ActiveRecord::Migration def change - add_index :event_schedules, [:event_id, :schedule_id], unique: true + add_index :event_schedules, %i[event_id schedule_id], unique: true end end diff --git a/db/migrate/20161229080315_add_comments_count_to_events.rb b/db/migrate/20161229080315_add_comments_count_to_events.rb index e1d6ebec..25e9ed58 100644 --- a/db/migrate/20161229080315_add_comments_count_to_events.rb +++ b/db/migrate/20161229080315_add_comments_count_to_events.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCommentsCountToEvents < ActiveRecord::Migration def change add_column :events, :comments_count, :integer, default: 0, null: false diff --git a/db/migrate/20170108053041_add_default_to_revision_in_conference.rb b/db/migrate/20170108053041_add_default_to_revision_in_conference.rb index 1c3571de..1e06838c 100644 --- a/db/migrate/20170108053041_add_default_to_revision_in_conference.rb +++ b/db/migrate/20170108053041_add_default_to_revision_in_conference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDefaultToRevisionInConference < ActiveRecord::Migration def change change_column :conferences, :revision, :integer, default: 0, null: false diff --git a/db/migrate/20170129075434_create_resources_table.rb b/db/migrate/20170129075434_create_resources_table.rb index 8228ddda..b3aec9df 100644 --- a/db/migrate/20170129075434_create_resources_table.rb +++ b/db/migrate/20170129075434_create_resources_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateResourcesTable < ActiveRecord::Migration def change create_table :resources do |t| diff --git a/db/migrate/20170212145523_add_enabled_to_event_schedules.rb b/db/migrate/20170212145523_add_enabled_to_event_schedules.rb index d89505fe..9d9cb819 100644 --- a/db/migrate/20170212145523_add_enabled_to_event_schedules.rb +++ b/db/migrate/20170212145523_add_enabled_to_event_schedules.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddEnabledToEventSchedules < ActiveRecord::Migration def change add_column :event_schedules, :enabled, :boolean, default: true diff --git a/db/migrate/20170213145807_change_email_public_from_users.rb b/db/migrate/20170213145807_change_email_public_from_users.rb index 2bbaffa6..adac2310 100644 --- a/db/migrate/20170213145807_change_email_public_from_users.rb +++ b/db/migrate/20170213145807_change_email_public_from_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeEmailPublicFromUsers < ActiveRecord::Migration def up change_column_default :users, :email_public, true diff --git a/db/migrate/20170302145716_add_schedule_interval_to_programs.rb b/db/migrate/20170302145716_add_schedule_interval_to_programs.rb index 617aaf1e..1cc8bdcc 100644 --- a/db/migrate/20170302145716_add_schedule_interval_to_programs.rb +++ b/db/migrate/20170302145716_add_schedule_interval_to_programs.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddScheduleIntervalToPrograms < ActiveRecord::Migration def change add_column :programs, :schedule_interval, :integer, default: 15, null: false diff --git a/db/migrate/20170419132148_add_week_to_ticket_purchases.rb b/db/migrate/20170419132148_add_week_to_ticket_purchases.rb index 0862eb16..1bdfe14e 100644 --- a/db/migrate/20170419132148_add_week_to_ticket_purchases.rb +++ b/db/migrate/20170419132148_add_week_to_ticket_purchases.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class AddWeekToTicketPurchases < ActiveRecord::Migration - class TmpTicketPurchase < ActiveRecord::Base + class TmpTicketPurchase < ApplicationRecord self.table_name = 'ticket_purchases' end diff --git a/db/migrate/20170516190048_create_booths.rb b/db/migrate/20170516190048_create_booths.rb index d2aa0be6..4c315511 100644 --- a/db/migrate/20170516190048_create_booths.rb +++ b/db/migrate/20170516190048_create_booths.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateBooths < ActiveRecord::Migration def change create_table :booths do |t| diff --git a/db/migrate/20170529215453_create_organizations.rb b/db/migrate/20170529215453_create_organizations.rb index 0fa5450b..ffa424cc 100644 --- a/db/migrate/20170529215453_create_organizations.rb +++ b/db/migrate/20170529215453_create_organizations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateOrganizations < ActiveRecord::Migration def change create_table :organizations do |t| diff --git a/db/migrate/20170530072155_add_type_to_cfps.rb b/db/migrate/20170530072155_add_type_to_cfps.rb index 50423281..9a5ccf6a 100644 --- a/db/migrate/20170530072155_add_type_to_cfps.rb +++ b/db/migrate/20170530072155_add_type_to_cfps.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class AddTypeToCfps < ActiveRecord::Migration - class TmpCfp < ActiveRecord::Base + class TmpCfp < ApplicationRecord self.table_name = 'cfps' end diff --git a/db/migrate/20170530112510_create_booth_requests.rb b/db/migrate/20170530112510_create_booth_requests.rb index 75e73a93..a6358a68 100644 --- a/db/migrate/20170530112510_create_booth_requests.rb +++ b/db/migrate/20170530112510_create_booth_requests.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateBoothRequests < ActiveRecord::Migration def change create_table :booth_requests do |t| diff --git a/db/migrate/20170531094819_move_conferences_to_organizations.rb b/db/migrate/20170531094819_move_conferences_to_organizations.rb index e70acf16..6cd3fdee 100644 --- a/db/migrate/20170531094819_move_conferences_to_organizations.rb +++ b/db/migrate/20170531094819_move_conferences_to_organizations.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + class MoveConferencesToOrganizations < ActiveRecord::Migration - class TempConference < ActiveRecord::Base + class TempConference < ApplicationRecord self.table_name = 'conferences' end - class TempOrganization < ActiveRecord::Base + class TempOrganization < ApplicationRecord self.table_name = 'organizations' end diff --git a/db/migrate/20170603095900_create_physical_tickets.rb b/db/migrate/20170603095900_create_physical_tickets.rb index 5e0c1d98..ef8abb65 100644 --- a/db/migrate/20170603095900_create_physical_tickets.rb +++ b/db/migrate/20170603095900_create_physical_tickets.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreatePhysicalTickets < ActiveRecord::Migration def change create_table :physical_tickets do |t| diff --git a/db/migrate/20170629162450_add_short_name_to_tracks.rb b/db/migrate/20170629162450_add_short_name_to_tracks.rb index cbc6b431..65e62256 100644 --- a/db/migrate/20170629162450_add_short_name_to_tracks.rb +++ b/db/migrate/20170629162450_add_short_name_to_tracks.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + class AddShortNameToTracks < ActiveRecord::Migration - class TmpProgram < ActiveRecord::Base + class TmpProgram < ApplicationRecord self.table_name = 'programs' end - class TmpTrack < ActiveRecord::Base + class TmpTrack < ApplicationRecord self.table_name = 'tracks' end diff --git a/db/migrate/20170629232817_add_ticket_layout_to_conferences.rb b/db/migrate/20170629232817_add_ticket_layout_to_conferences.rb index c07f85c3..faf67332 100644 --- a/db/migrate/20170629232817_add_ticket_layout_to_conferences.rb +++ b/db/migrate/20170629232817_add_ticket_layout_to_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddTicketLayoutToConferences < ActiveRecord::Migration def change add_column :conferences, :ticket_layout, :integer, default: 0 diff --git a/db/migrate/20170705075039_add_state_cfp_active_and_submitter_reference_to_tracks.rb b/db/migrate/20170705075039_add_state_cfp_active_and_submitter_reference_to_tracks.rb index 9cb7f7de..b42cf9c2 100644 --- a/db/migrate/20170705075039_add_state_cfp_active_and_submitter_reference_to_tracks.rb +++ b/db/migrate/20170705075039_add_state_cfp_active_and_submitter_reference_to_tracks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddStateCfpActiveAndSubmitterReferenceToTracks < ActiveRecord::Migration def change add_column :tracks, :state, :string diff --git a/db/migrate/20170711102511_create_ticket_scannings.rb b/db/migrate/20170711102511_create_ticket_scannings.rb index d1879f68..12c20eb1 100644 --- a/db/migrate/20170711102511_create_ticket_scannings.rb +++ b/db/migrate/20170711102511_create_ticket_scannings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateTicketScannings < ActiveRecord::Migration def change create_table :ticket_scannings do |t| diff --git a/db/migrate/20170712120556_add_room_and_dates_to_tracks.rb b/db/migrate/20170712120556_add_room_and_dates_to_tracks.rb index fb8a064b..6c2d92b9 100644 --- a/db/migrate/20170712120556_add_room_and_dates_to_tracks.rb +++ b/db/migrate/20170712120556_add_room_and_dates_to_tracks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRoomAndDatesToTracks < ActiveRecord::Migration def change add_reference :tracks, :room, index: true, foreign_key: true diff --git a/db/migrate/20170715131706_make_track_state_not_null_and_add_default_value.rb b/db/migrate/20170715131706_make_track_state_not_null_and_add_default_value.rb index 3d2520cf..beae99cc 100644 --- a/db/migrate/20170715131706_make_track_state_not_null_and_add_default_value.rb +++ b/db/migrate/20170715131706_make_track_state_not_null_and_add_default_value.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class MakeTrackStateNotNullAndAddDefaultValue < ActiveRecord::Migration - class TmpTrack < ActiveRecord::Base + class TmpTrack < ApplicationRecord self.table_name = 'tracks' end diff --git a/db/migrate/20170720134353_make_track_cfp_active_not_null.rb b/db/migrate/20170720134353_make_track_cfp_active_not_null.rb index 0f75d046..cfc8b1a5 100644 --- a/db/migrate/20170720134353_make_track_cfp_active_not_null.rb +++ b/db/migrate/20170720134353_make_track_cfp_active_not_null.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class MakeTrackCfpActiveNotNull < ActiveRecord::Migration - class TmpTrack < ActiveRecord::Base + class TmpTrack < ApplicationRecord self.table_name = 'tracks' end diff --git a/db/migrate/20170721001700_add_index_to_physical_tickets.rb b/db/migrate/20170721001700_add_index_to_physical_tickets.rb index 46a0b8c0..042430fe 100644 --- a/db/migrate/20170721001700_add_index_to_physical_tickets.rb +++ b/db/migrate/20170721001700_add_index_to_physical_tickets.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddIndexToPhysicalTickets < ActiveRecord::Migration def change add_column :physical_tickets, :token, :string diff --git a/db/migrate/20170721184810_add_custom_domain_to_conferences.rb b/db/migrate/20170721184810_add_custom_domain_to_conferences.rb index d5aef4fd..a3e2897b 100644 --- a/db/migrate/20170721184810_add_custom_domain_to_conferences.rb +++ b/db/migrate/20170721184810_add_custom_domain_to_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCustomDomainToConferences < ActiveRecord::Migration def change add_column :conferences, :custom_domain, :string diff --git a/db/migrate/20170726065629_add_relevance_to_tracks.rb b/db/migrate/20170726065629_add_relevance_to_tracks.rb index 215200c1..7db35227 100644 --- a/db/migrate/20170726065629_add_relevance_to_tracks.rb +++ b/db/migrate/20170726065629_add_relevance_to_tracks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRelevanceToTracks < ActiveRecord::Migration def change add_column :tracks, :relevance, :text diff --git a/db/migrate/20170727081731_add_include_booths_to_splashpages.rb b/db/migrate/20170727081731_add_include_booths_to_splashpages.rb index da11ea8d..ea5882c1 100644 --- a/db/migrate/20170727081731_add_include_booths_to_splashpages.rb +++ b/db/migrate/20170727081731_add_include_booths_to_splashpages.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddIncludeBoothsToSplashpages < ActiveRecord::Migration def change add_column :splashpages, :include_booths, :boolean diff --git a/db/migrate/20170728182033_add_booth_limit_to_conferences.rb b/db/migrate/20170728182033_add_booth_limit_to_conferences.rb index 60643784..ae0f1410 100644 --- a/db/migrate/20170728182033_add_booth_limit_to_conferences.rb +++ b/db/migrate/20170728182033_add_booth_limit_to_conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddBoothLimitToConferences < ActiveRecord::Migration def change add_column :conferences, :booth_limit, :integer, default: 0 diff --git a/db/migrate/20170731161207_add_booths_to_email_settings.rb b/db/migrate/20170731161207_add_booths_to_email_settings.rb index 0b3a7a87..5df76759 100644 --- a/db/migrate/20170731161207_add_booths_to_email_settings.rb +++ b/db/migrate/20170731161207_add_booths_to_email_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddBoothsToEmailSettings < ActiveRecord::Migration def change add_column :email_settings, :send_on_booths_acceptance, :boolean, default: false diff --git a/db/migrate/20170807092805_add_registration_ticket_to_tickets.rb b/db/migrate/20170807092805_add_registration_ticket_to_tickets.rb index 0ee2410d..c2e4fd8e 100644 --- a/db/migrate/20170807092805_add_registration_ticket_to_tickets.rb +++ b/db/migrate/20170807092805_add_registration_ticket_to_tickets.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRegistrationTicketToTickets < ActiveRecord::Migration def change add_column :tickets, :registration_ticket, :boolean, default: false diff --git a/db/migrate/20170809120927_add_track_reference_to_schedule.rb b/db/migrate/20170809120927_add_track_reference_to_schedule.rb index 2c2d7f1c..b98fca24 100644 --- a/db/migrate/20170809120927_add_track_reference_to_schedule.rb +++ b/db/migrate/20170809120927_add_track_reference_to_schedule.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddTrackReferenceToSchedule < ActiveRecord::Migration def change add_reference :schedules, :track, index: true, foreign_key: true diff --git a/db/migrate/20170814174637_add_selected_schedule_to_tracks.rb b/db/migrate/20170814174637_add_selected_schedule_to_tracks.rb index 05b7d417..bedc96c3 100644 --- a/db/migrate/20170814174637_add_selected_schedule_to_tracks.rb +++ b/db/migrate/20170814174637_add_selected_schedule_to_tracks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSelectedScheduleToTracks < ActiveRecord::Migration def change add_column :tracks, :selected_schedule_id, :integer diff --git a/db/migrate/20170905110034_add_description_to_cfps.rb b/db/migrate/20170905110034_add_description_to_cfps.rb index a4976ee2..968a907c 100644 --- a/db/migrate/20170905110034_add_description_to_cfps.rb +++ b/db/migrate/20170905110034_add_description_to_cfps.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDescriptionToCfps < ActiveRecord::Migration def change add_column :cfps, :description, :text diff --git a/db/migrate/20170924190528_add_amount_paid_to_ticket_purchases.rb b/db/migrate/20170924190528_add_amount_paid_to_ticket_purchases.rb index 5e732d4c..f3357ee3 100644 --- a/db/migrate/20170924190528_add_amount_paid_to_ticket_purchases.rb +++ b/db/migrate/20170924190528_add_amount_paid_to_ticket_purchases.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddAmountPaidToTicketPurchases < ActiveRecord::Migration def change add_column :ticket_purchases, :amount_paid, :float, default: 0 diff --git a/db/migrate/20171118113113_change_visit_id_type_of_ahoy_events_to_integer.rb b/db/migrate/20171118113113_change_visit_id_type_of_ahoy_events_to_integer.rb index 61415970..58b08609 100644 --- a/db/migrate/20171118113113_change_visit_id_type_of_ahoy_events_to_integer.rb +++ b/db/migrate/20171118113113_change_visit_id_type_of_ahoy_events_to_integer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeVisitIdTypeOfAhoyEventsToInteger < ActiveRecord::Migration[5.0] def change change_column :ahoy_events, :visit_id, :integer, limit: nil diff --git a/db/migrate/20171130172334_rebuild_conference_pictures.rb b/db/migrate/20171130172334_rebuild_conference_pictures.rb index a8d74bce..c19ae041 100644 --- a/db/migrate/20171130172334_rebuild_conference_pictures.rb +++ b/db/migrate/20171130172334_rebuild_conference_pictures.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RebuildConferencePictures < ActiveRecord::Migration def up Conference.all.each do |conference| diff --git a/db/migrate/20171201163628_add_mastodon_to_contact.rb b/db/migrate/20171201163628_add_mastodon_to_contact.rb index 9b022019..a3cc50b6 100644 --- a/db/migrate/20171201163628_add_mastodon_to_contact.rb +++ b/db/migrate/20171201163628_add_mastodon_to_contact.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddMastodonToContact < ActiveRecord::Migration def change add_column :contacts, :mastodon, :string diff --git a/db/migrate/20180226032958_add_created_at_and_updated_at_to_event_types.rb b/db/migrate/20180226032958_add_created_at_and_updated_at_to_event_types.rb index ce8d3c11..ea2a1542 100644 --- a/db/migrate/20180226032958_add_created_at_and_updated_at_to_event_types.rb +++ b/db/migrate/20180226032958_add_created_at_and_updated_at_to_event_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCreatedAtAndUpdatedAtToEventTypes < ActiveRecord::Migration[5.0] def up add_column :event_types, :created_at, :datetime diff --git a/db/migrate/20180313012253_add_timestamps_to_tickets.rb b/db/migrate/20180313012253_add_timestamps_to_tickets.rb index 85e8407e..eb2838db 100644 --- a/db/migrate/20180313012253_add_timestamps_to_tickets.rb +++ b/db/migrate/20180313012253_add_timestamps_to_tickets.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddTimestampsToTickets < ActiveRecord::Migration[5.0] def up add_column :tickets, :created_at, :datetime diff --git a/db/seeds.rb b/db/seeds.rb index bf3567e0..88d2d10a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # diff --git a/lib/tasks/capitalize_colors.rake b/lib/tasks/capitalize_colors.rake index 48b9b4ef..aa80c688 100644 --- a/lib/tasks/capitalize_colors.rake +++ b/lib/tasks/capitalize_colors.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :data do desc 'Catitalize tracks, event types and difficult levels colors' diff --git a/lib/tasks/cleardb.rake b/lib/tasks/cleardb.rake index ca2a32ae..2cf19a2a 100644 --- a/lib/tasks/cleardb.rake +++ b/lib/tasks/cleardb.rake @@ -1,8 +1,8 @@ +# frozen_string_literal: true + namespace :db do desc 'setup DATABASE_URL from CLEARDB_DATABASE_URL in config/database.yml' task 'cleardb_env' do - unless ENV['CLEARDB_DATABASE_URL'].nil? - FileUtils.copy_file('config/database.yml.heroku', 'config/database.yml') - end + FileUtils.copy_file('config/database.yml.heroku', 'config/database.yml') unless ENV['CLEARDB_DATABASE_URL'].nil? end end diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index 215a1efe..3935b1be 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :data do desc 'Nullify wrong foreign keys' @@ -20,7 +22,7 @@ namespace :data do if collection.any? puts "IDs: #{collection.map(&:id)}" collection.each do |item| - item.send(attribute+'=', nil) + item.send(attribute + '=', nil) item.save! end puts "Fixed #{attribute}!" diff --git a/lib/tasks/data_demo.rake b/lib/tasks/data_demo.rake index 8debfe49..6ad5ec4b 100644 --- a/lib/tasks/data_demo.rake +++ b/lib/tasks/data_demo.rake @@ -1,10 +1,12 @@ +# frozen_string_literal: true + namespace :data do desc 'Create demo data using our factories' task demo: :environment do include FactoryGirl::Syntax::Methods - conference = create(:full_conference, title: 'Open Source Event Manager Demo', short_title: 'osemdemo' ,description: "This is a [Open Source Event Manager](http://osem.io/) demo instance. You can log in as **admin** with the password **password123** or just you just [sign up](/accounts/sign_up) with your own user. We hope you enjoy checking out all the functionality, if you have questions don't hesitate to [contact us](http://osem.io/#contact)!\r\n\r\n## Data will be destroyed every thirty minutes or whenever someone updates the [OSEM source code on github](https://github.com/openSUSE/osem/commits/master).") - conference.contact.update_attributes(email: 'osemdemo@osem.io', sponsor_email: 'osemdemo@osem.io') + conference = create(:full_conference, title: 'Open Source Event Manager Demo', short_title: 'osemdemo', description: "This is a [Open Source Event Manager](http://osem.io/) demo instance. You can log in as **admin** with the password **password123** or just you just [sign up](/accounts/sign_up) with your own user. We hope you enjoy checking out all the functionality, if you have questions don't hesitate to [contact us](http://osem.io/#contact)!\r\n\r\n## Data will be destroyed every thirty minutes or whenever someone updates the [OSEM source code on github](https://github.com/openSUSE/osem/commits/master).") + conference.contact.update(email: 'osemdemo@osem.io', sponsor_email: 'osemdemo@osem.io') create(:admin, email: 'admin@osem.io', username: 'admin', password: 'password123', password_confirmation: 'password123') end end diff --git a/lib/tasks/demo_data_for_development.rake b/lib/tasks/demo_data_for_development.rake index 5be30c8e..95c0a694 100644 --- a/lib/tasks/demo_data_for_development.rake +++ b/lib/tasks/demo_data_for_development.rake @@ -1,9 +1,11 @@ +# frozen_string_literal: true + namespace :data do desc 'Create demo data for our local development' task test: :environment do include FactoryGirl::Syntax::Methods - def generate_program conference + def generate_program(conference) program = conference.program user1 = create(:user) user2 = create(:user) @@ -12,7 +14,7 @@ namespace :data do selected_schedule = create(:schedule, program: program) demo_schedule = create(:schedule, program: program) - program.update_attributes!(selected_schedule: selected_schedule) + program.update!(selected_schedule: selected_schedule) create(:event, program: program, title: 'Demo Event', abstract: 'This is a demo event instance whose state not defined.') create(:event, program: program, title: 'Demo Rejected Event', state: 'rejected', abstract: 'This is demo event instance in a rejected state.') @@ -48,9 +50,9 @@ namespace :data do # So that events can be created without any failure in validations. conference = create(:full_conference, title: 'Jangouts Demo Conference', short_title: 'jangouts', start_date: 7.days.ago, end_date: 6.days.from_now, start_hour: 15, end_hour: 20, description: 'This is a full conference demo instance happened in the past. It contains open cfp, venue/rooms, submitted talks by multiple speakers, partly confirmed talks and multiple schedules.') generate_program conference - conference.program.cfp.update_attributes!(start_date: 4.days.ago, end_date: 2.days.ago) - conference.update_attributes!(end_date: 1.day.ago) - conference.registration_period.update_attributes!(start_date: 9.days.ago, end_date: 8.days.ago) + conference.program.cfp.update!(start_date: 4.days.ago, end_date: 2.days.ago) + conference.update!(end_date: 1.day.ago) + conference.registration_period.update!(start_date: 9.days.ago, end_date: 8.days.ago) # This is a conference that will happen in the future # It only has a registration period and unscheduled events diff --git a/lib/tasks/dump_db.rake b/lib/tasks/dump_db.rake index 6738f409..71b557f4 100644 --- a/lib/tasks/dump_db.rake +++ b/lib/tasks/dump_db.rake @@ -1,11 +1,13 @@ +# frozen_string_literal: true + require 'yaml' task :dump_db do - yaml = YAML.load_file("config/database.yml") - conf = yaml["production"] - filename = "#{conf["database"]}-#{Time.now.strftime("%Y-%m-%d-%H:%M:%S:%L")}.sql" - if conf["adapter"] == 'mysql2' - system "mysqldump -u #{conf["username"]} --password=#{conf["password"]} -h #{conf["host"]} #{conf["database"]} > ~/#{filename}" + yaml = YAML.load_file('config/database.yml') + conf = yaml['production'] + filename = "#{conf['database']}-#{Time.now.strftime('%Y-%m-%d-%H:%M:%S:%L')}.sql" + if conf['adapter'] == 'mysql2' + system "mysqldump -u #{conf['username']} --password=#{conf['password']} -h #{conf['host']} #{conf['database']} > ~/#{filename}" else - puts "Error: This rake task only works for MYSQL" + puts 'Error: This rake task only works for MYSQL' end end diff --git a/lib/tasks/event_attatchments.rake b/lib/tasks/event_attatchments.rake index 46985168..93d83600 100644 --- a/lib/tasks/event_attatchments.rake +++ b/lib/tasks/event_attatchments.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :db do desc 'Destroy event_attachments versions' @@ -5,4 +7,4 @@ namespace :db do PaperTrail::Version.where(item_type: 'EventAttachment').try(:destroy_all) puts 'Version records with event_attachment have been destroyed' end -end \ No newline at end of file +end diff --git a/lib/tasks/events_registrations.rake b/lib/tasks/events_registrations.rake index 726b739b..6b6030bc 100644 --- a/lib/tasks/events_registrations.rake +++ b/lib/tasks/events_registrations.rake @@ -1,25 +1,24 @@ +# frozen_string_literal: true + namespace :events_registrations do - desc "Deletes dupicate entries" + desc 'Deletes dupicate entries' task deduplicate: :environment do - if ActiveRecord::Migrator.get_all_versions.include? 20160403214841 - duplicates = EventsRegistration.all.map { |er| er.id if er.valid? == false}.compact + if ActiveRecord::Migrator.get_all_versions.include? 20_160_403_214_841 + duplicates = EventsRegistration.all.map { |er| er.id if er.valid? == false }.compact puts "Duplicates found: #{duplicates.count}" - if duplicates.count > 0 - puts "With IDs: #{duplicates}" - end + puts "With IDs: #{duplicates}" if duplicates.count > 0 EventsRegistration.all.each do |er| records = EventsRegistration.where(registration_id: er.registration_id, event_id: er.event_id) - if records.count > 1 - # Iterate through duplicates (excluding 1st record) - (1..(records.count - 1)).each do |i| - puts "Deleting EventsRegistration record with ID #{records[i].id} ..." - if records[i].destroy - puts 'Succeeded!' - else - puts 'Faild!' - end + next unless records.count > 1 + # Iterate through duplicates (excluding 1st record) + (1..(records.count - 1)).each do |i| + puts "Deleting EventsRegistration record with ID #{records[i].id} ..." + if records[i].destroy + puts 'Succeeded!' + else + puts 'Faild!' end end end diff --git a/lib/tasks/factory_girl.rake b/lib/tasks/factory_girl.rake index bccc1b66..9de62236 100644 --- a/lib/tasks/factory_girl.rake +++ b/lib/tasks/factory_girl.rake @@ -1,5 +1,7 @@ +# frozen_string_literal: true + namespace :factory_girl do - desc "Verify that all FactoryGirl factories are valid" + desc 'Verify that all FactoryGirl factories are valid' task lint: :environment do if Rails.env.test? begin diff --git a/lib/tasks/logo.rake b/lib/tasks/logo.rake index 468b6d72..082bded4 100644 --- a/lib/tasks/logo.rake +++ b/lib/tasks/logo.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :data do namespace :migrate do desc 'Resize existing logo of sponsors after change in image manipulation specifications' diff --git a/lib/tasks/migrate_config.rake b/lib/tasks/migrate_config.rake index 452a061f..ab077c31 100644 --- a/lib/tasks/migrate_config.rake +++ b/lib/tasks/migrate_config.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :data do namespace :migrate do desc 'Create a dotenv file from config/config.yml' @@ -14,8 +16,8 @@ namespace :data do config_yml = Rails.root.join('config', 'config.yml') begin CONFIG = YAML.load_file(config_yml)[Rails.env] - rescue - CONFIG = {} + rescue StandardError + CONFIG = {}.freeze end # Write the dotenv file @@ -23,7 +25,7 @@ namespace :data do dot_env.puts "OSEM_NAME=\"#{CONFIG['name']}\"" dot_env.puts "OSEM_HOSTNAME=\"#{CONFIG['url_for_emails']}\"" dot_env.puts "OSEM_EMAIL_ADDRESS=\"#{CONFIG['sender_for_emails']}\"" - dot_env.puts "OSEM_ICHAIN_ENABLED=\"#{CONFIG['authentication']['ichain']['enabled']}\"" if CONFIG.has_key?(:authentication) + dot_env.puts "OSEM_ICHAIN_ENABLED=\"#{CONFIG['authentication']['ichain']['enabled']}\"" if CONFIG.key?(:authentication) dot_env.puts "OSEM_TRANSIFEX_APIKEY=\"#{CONFIG['transifex_live_api_key']}\"" dot_env.puts "OSEM_ERRBIT_HOST=\"#{CONFIG['errbit_host']}\"" dot_env.puts "OSEM_FACTORY_LINT=\"#{CONFIG['factory_girl_lint']}\"" diff --git a/lib/tasks/normalize_resources.rake b/lib/tasks/normalize_resources.rake index e05d0d69..6ee5f92d 100644 --- a/lib/tasks/normalize_resources.rake +++ b/lib/tasks/normalize_resources.rake @@ -1,12 +1,12 @@ +# frozen_string_literal: true + namespace :data do desc 'Update resources with nil quantity/used fields' task normalize_resources: :environment do Resource.where('used is ? or quantity is ?', nil, nil).each do |resource| resource.used = 0 if resource.used.blank? resource.quantity = resource.used if resource.quantity.blank? - unless resource.save - puts "Failed to update resource #{resource.name} (ID #{resource.id})" - end + puts "Failed to update resource #{resource.name} (ID #{resource.id})" unless resource.save end end end diff --git a/lib/tasks/roles.rake b/lib/tasks/roles.rake index c29d0e24..19848eab 100644 --- a/lib/tasks/roles.rake +++ b/lib/tasks/roles.rake @@ -1,7 +1,8 @@ +# frozen_string_literal: true + namespace :roles do desc 'Adds back deleted roles to all conferences' task add: :environment do - Organization.all.each do |org| Role.where(name: 'organization_admin', resource: org).first_or_create(description: 'For the administrators of an organization and its conferences') end @@ -16,4 +17,3 @@ namespace :roles do puts 'All done!' end end - diff --git a/lib/tasks/several_schedules.rake b/lib/tasks/several_schedules.rake index f83b9664..9c69b8a7 100644 --- a/lib/tasks/several_schedules.rake +++ b/lib/tasks/several_schedules.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :data do desc 'Move the start_time and room attributes from Event to EventSchedule' @@ -7,16 +9,15 @@ namespace :data do program.selected_schedule = schedule program.save program.events.each do |event| - unless event.start_time.nil? && event.room_id.nil? - # we can not use .room as this relation has been removed - EventSchedule.create(event: event, - schedule: schedule, - start_time: event.start_time, - room_id: event.room_id) - event.start_time = nil - event.room_id = nil - event.save - end + next if event.start_time.nil? && event.room_id.nil? + # we can not use .room as this relation has been removed + EventSchedule.create(event: event, + schedule: schedule, + start_time: event.start_time, + room_id: event.room_id) + event.start_time = nil + event.room_id = nil + event.save end end puts 'The start_time and room attributes has been moved from Event to EventSchedule' diff --git a/lib/tasks/user.rake b/lib/tasks/user.rake index 97e56e40..6ab7258a 100644 --- a/lib/tasks/user.rake +++ b/lib/tasks/user.rake @@ -1,21 +1,20 @@ -namespace :user do - desc "Makes is_admin attribute true for user based on the supplied email address." - task :admin, [:email] => :environment do |t, args| +# frozen_string_literal: true +namespace :user do + desc 'Makes is_admin attribute true for user based on the supplied email address.' + task :admin, [:email] => :environment do |_t, args| # Check if an email address was supplied - fail 'You need to define the email address of the user you want to make an admin.' unless args.email + raise 'You need to define the email address of the user you want to make an admin.' unless args.email user = User.find_by(email: args.email) # Check if a user is found based on the supplied email address - fail "There is no user with email #{args.email}!" unless user + raise "There is no user with email #{args.email}!" unless user - if user.update_columns(is_admin: true) - puts "User with email #{args.email} is now an admin!" - end + puts "User with email #{args.email} is now an admin!" if user.update_columns(is_admin: true) end - desc "Set email_public attrubute true for all users" - task :set_email_public => :environment do + desc 'Set email_public attrubute true for all users' + task set_email_public: :environment do User.update_all email_public: true end end diff --git a/lib/tasks/version.rake b/lib/tasks/version.rake index a25653c6..813a9cf4 100644 --- a/lib/tasks/version.rake +++ b/lib/tasks/version.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :data do desc 'Sets conference_id in all pre-existing PaperTrail::Version objects' task set_conference_in_versions: :environment do @@ -5,7 +7,7 @@ namespace :data do PaperTrail::Version.where(conference_id: nil, item_type: %w[Conference Event]).each do |version| # All pre-existing versions are either of Conference or Event if version.item_type == 'Conference' - version.update_attributes(conference_id: version.item_id) + version.update(conference_id: version.item_id) elsif version.item_type == 'Event' event = (version.item || version.reify || version.next.reify) @@ -24,7 +26,7 @@ namespace :data do puts "Setting conference_id value failed for PaperTrail::Version object with ID=#{version.id}" nil end - version.update_attributes(conference_id: conference_id) + version.update(conference_id: conference_id) end end puts 'All done!' diff --git a/spec/controllers/admin/booths_controller_spec.rb b/spec/controllers/admin/booths_controller_spec.rb index 37004531..4fee4038 100644 --- a/spec/controllers/admin/booths_controller_spec.rb +++ b/spec/controllers/admin/booths_controller_spec.rb @@ -1,24 +1,24 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::BoothsController do - let(:admin) { create(:admin) } let(:conference) { create(:conference) } let(:booth) { create(:booth, title: 'Title', conference: conference) } let(:admin) { create(:admin) } context 'not logged in user' do - describe 'GET index' do it 'does not render admin/booths#index' do - get :index, conference_id: conference.short_title + get :index, params: { conference_id: conference.short_title } expect(response).to redirect_to(user_session_path) end end describe 'GET show' do it 'does not render admin/booths#show' do - get :show, id: booth.id, conference_id: conference.short_title + get :show, params: { id: booth.id, conference_id: conference.short_title } expect(response).to redirect_to(user_session_path) end end @@ -30,7 +30,7 @@ describe Admin::BoothsController do end describe 'GET index' do - before { get :index, conference_id: conference.short_title } + before { get :index, params: { conference_id: conference.short_title } } it 'assigns attributes for booths' do expect(assigns(:booths)).to eq([booth]) @@ -42,7 +42,7 @@ describe Admin::BoothsController do end describe 'GET new' do - before { get :new, conference_id: conference.short_title } + before { get :new, params: { conference_id: conference.short_title } } it 'assigns attributes for booths' do expect(assigns(:booth)).to be_a_new(Booth) @@ -55,11 +55,11 @@ describe Admin::BoothsController do describe 'POST #create' do context 'successfully created' do - before { post :create, booth: attributes_for(:booth), conference_id: conference.short_title } + before { post :create, params: { booth: attributes_for(:booth), conference_id: conference.short_title } } it 'creates a new booth' do expected = expect do - post :create, booth: attributes_for(:booth), conference_id: conference.short_title + post :create, params: { booth: attributes_for(:booth), conference_id: conference.short_title } end expected.to change { Booth.count }.by(1) end @@ -78,11 +78,11 @@ describe Admin::BoothsController do end context 'create action fails' do - before { post :create, booth: attributes_for(:booth, title: ''), conference_id: conference.short_title } + before { post :create, params: { booth: attributes_for(:booth, title: ''), conference_id: conference.short_title } } it 'does not create any record' do expected = expect do - post :create, booth: attributes_for(:booth, title: ''), conference_id: conference.short_title + post :create, params: { booth: attributes_for(:booth, title: ''), conference_id: conference.short_title } end expected.to_not change(Booth, :count) end @@ -98,7 +98,7 @@ describe Admin::BoothsController do end describe 'GET #edit' do - before { get :edit, id: booth.id, conference_id: conference.short_title } + before { get :edit, params: { id: booth.id, conference_id: conference.short_title } } it 'renders edit template' do expect(response).to render_template('edit') @@ -111,7 +111,7 @@ describe Admin::BoothsController do describe 'PATCH #update' do context 'updates suchessfully' do - before { patch :update, id: booth.id, booth: attributes_for(:booth, title: 'different'), conference_id: conference.short_title } + before { patch :update, params: { id: booth.id, booth: attributes_for(:booth, title: 'different'), conference_id: conference.short_title } } it 'redirects to admin booth index path' do expect(response).to redirect_to admin_conference_booths_path end diff --git a/spec/controllers/admin/comments_controller_spec.rb b/spec/controllers/admin/comments_controller_spec.rb index 23b6b88a..89526e89 100644 --- a/spec/controllers/admin/comments_controller_spec.rb +++ b/spec/controllers/admin/comments_controller_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::CommentsController, type: :controller do - # It is necessary to use bang version of let to build roles before user let(:conference) { create(:conference) } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index 23e6afd2..9500dcbb 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -1,10 +1,11 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::ConferencesController do - # It is necessary to use bang version of let to build roles before user let!(:organization) { create(:organization, name: 'organization') } - let!(:conference) { create(:conference, organization: organization, end_date: Date.new(2014, 05, 26) + 15) } + let!(:conference) { create(:conference, organization: organization, end_date: Date.new(2014, 0o5, 26) + 15) } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } let!(:organization_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) } let(:organization_admin) { create(:user, role_ids: organization_admin_role.id) } @@ -16,32 +17,33 @@ describe Admin::ConferencesController do describe 'PATCH #update' do context 'valid attributes' do it 'locates the requested conference' do - patch :update, id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con') + patch :update, params: { id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con') } expect(assigns(:conference)).to eq(conference) end it 'changes conference attributes' do - patch :update, id: conference.short_title, conference: + patch :update, params: { id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con', - short_title: 'ExCon') + short_title: 'ExCon') } conference.reload expect(conference.title).to eq('Example Con') expect(conference.short_title).to eq('ExCon') end it 'redirects to the updated conference' do - patch :update, id: conference.short_title, conference: - attributes_for(:conference, title: 'Example Con') + patch :update, params: { id: conference.short_title, conference: + attributes_for(:conference, title: 'Example Con') } conference.reload expect(response).to redirect_to edit_admin_conference_path( - conference.short_title) + conference.short_title + ) end it 'sends email notification on conference date update' do mailer = double allow(mailer).to receive(:deliver) conference.email_settings = create(:email_settings) - patch :update, id: conference.short_title, conference: attributes_for(:conference, start_date: Time.zone.today + 2.days, end_date: Time.zone.today + 4.days) + patch :update, params: { id: conference.short_title, conference: attributes_for(:conference, start_date: Time.zone.today + 2.days, end_date: Time.zone.today + 4.days) } conference.reload allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer) end @@ -49,50 +51,51 @@ describe Admin::ConferencesController do context 'invalid attributes' do it 'does not change conference attributes' do - patch :update, id: conference.short_title, conference: + patch :update, params: { id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con', - short_title: nil) + short_title: nil) } conference.reload expect(flash[:error]) - .to eq("Updating conference failed. Short title can't be blank.") + .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 it 're-renders the #show template' do - patch :update, id: conference.short_title, conference: + patch :update, params: { id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con', - short_title: nil) + short_title: nil) } expect(flash[:error]) - .to eq("Updating conference failed. Short title can't be blank.") + .to eq("Updating conference failed. Short title can't be blank.") expect(response).to redirect_to edit_admin_conference_path( - conference.short_title) + conference.short_title + ) end end end describe 'GET #edit' do it 'assigns the requested conference to conference' do - get :edit, id: conference.short_title + get :edit, params: { id: conference.short_title } expect(assigns(:conference)).to eq conference end it 'renders the show template' do - get :edit, id: conference.short_title + get :edit, params: { id: conference.short_title } expect(response).to render_template :edit end end describe 'GET #show' do it 'assigns the requested conference to conference' do - get :show, id: conference.short_title + get :show, params: { id: conference.short_title } expect(assigns(:conference)).to eq conference end it 'renders the show template' do - get :show, id: conference.short_title + get :show, params: { id: conference.short_title } expect(response).to render_template :show end @@ -101,11 +104,11 @@ describe Admin::ConferencesController do create(:event, program: conference.program) workshop = create(:event_type, title: 'Workshop', color: '#000000', program: conference.program) lecture = create(:event_type, title: 'Lecture', color: '#ffffff', program: conference.program) - get :show, id: conference.short_title + get :show, params: { id: conference.short_title } expect(assigns(:event_type_distribution_withdrawn)).to be_empty create(:event, program: conference.program, state: 'withdrawn', event_type: lecture) create(:event, program: conference.program, state: 'withdrawn', event_type: workshop) - get :show, id: conference.short_title + get :show, params: { id: conference.short_title } expect(assigns(:event_type_distribution_withdrawn)).not_to be_empty result = {} result['Workshop'] = { @@ -122,13 +125,13 @@ describe Admin::ConferencesController do it 'assigns conference withdrawn difficulty level distribution to difficulty_levels_distribution_withdrawn' do conference create(:event, program: conference.program) - get :show, id: conference.short_title + get :show, params: { id: conference.short_title } expect(assigns(:difficulty_levels_distribution_withdrawn)).to be_empty easy = create(:difficulty_level, title: 'Easy', color: '#000000') hard = create(:difficulty_level, title: 'Hard', color: '#ffffff') create(:event, program: conference.program, state: 'withdrawn', difficulty_level: easy) create(:event, program: conference.program, state: 'withdrawn', difficulty_level: hard) - get :show, id: conference.short_title + get :show, params: { id: conference.short_title } expect(assigns(:difficulty_levels_distribution_withdrawn)).not_to be_empty result = {} result['Easy'] = { @@ -145,13 +148,13 @@ describe Admin::ConferencesController do it 'assigns conference withdrawn track distribution to tracks_distribution_withdrawn' do conference create(:event, program: conference.program) - get :show, id: conference.short_title + get :show, params: { id: conference.short_title } expect(assigns(:tracks_distribution_withdrawn)).to be_empty track_one = create(:track, name: 'Track One', color: '#000000', program: conference.program) track_two = create(:track, name: 'Track Two', color: '#FFFFFF', program: conference.program) create(:event, program: conference.program, state: 'withdrawn', track: track_one) create(:event, program: conference.program, state: 'withdrawn', track: track_two) - get :show, id: conference.short_title + get :show, params: { id: conference.short_title } expect(assigns(:tracks_distribution_withdrawn)).not_to be_empty result = {} result['Track One'] = { @@ -177,7 +180,7 @@ describe Admin::ConferencesController do it 'assigns cfp_max an array with maximum weeks' do conference - date = Date.new(2014, 05, 26) + date = Date.new(2014, 0o5, 26) create(:cfp, program: conference.program, start_date: date, @@ -195,9 +198,7 @@ describe Admin::ConferencesController do context 'no conferences' do it 'redirect to new conference' do - Conference.all.each do |c| - c.destroy - end + Conference.all.each(&:destroy) sign_in create(:admin) get :index expect(response).to redirect_to new_admin_conference_path @@ -211,18 +212,19 @@ describe Admin::ConferencesController do context 'with valid attributes' do it 'saves the conference to the database' do expected = expect do - post :create, conference: - attributes_for(:conference, short_title: 'dps15', organization_id: organization.id) + post :create, params: { conference: + attributes_for(:conference, short_title: 'dps15', organization_id: organization.id) } end expected.to change { Conference.count }.by 1 end it 'redirects to conference#show' do - post :create, conference: - attributes_for(:conference, short_title: 'dps15', organization_id: organization.id) + post :create, params: { conference: + attributes_for(:conference, short_title: 'dps15', organization_id: organization.id) } expect(response).to redirect_to admin_conference_path( - assigns[:conference].short_title) + assigns[:conference].short_title + ) end it 'creates roles for the conference' do @@ -230,8 +232,8 @@ describe Admin::ConferencesController do info_desk_role = Role.find_by(name: 'info_desk', resource: conference) volunteers_coordinator_role = Role.find_by(name: 'volunteers_coordinator', resource: conference) - post :create, conference: - attributes_for(:conference, short_title: 'dps15') + post :create, params: { conference: + attributes_for(:conference, short_title: 'dps15') } expect(conference.roles.count).to eq 4 @@ -242,15 +244,15 @@ describe Admin::ConferencesController do context 'with invalid attributes' do it 'does not save the conference to the database' do expected = expect do - post :create, conference: - attributes_for(:conference, short_title: nil, organization_id: organization.id) + post :create, params: { conference: + attributes_for(:conference, short_title: nil, organization_id: organization.id) } end expected.to_not change { Conference.count } end it 're-renders the new template' do - post :create, conference: - attributes_for(:conference, short_title: nil, organization_id: organization.id) + post :create, params: { conference: + attributes_for(:conference, short_title: nil, organization_id: organization.id) } expect(response).to be_success end end @@ -259,15 +261,15 @@ describe Admin::ConferencesController do it 'does not save the conference to the database' do conference expected = expect do - post :create, conference: - attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id) + post :create, params: { conference: + attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id) } end expected.to_not change { Conference.count } end it 're-renders the new template' do conference - post :create, conference: attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id) + post :create, params: { conference: attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id) } expect(response).to be_success end end @@ -300,20 +302,16 @@ describe Admin::ConferencesController do it 'requires organizer privileges' do get :new expect(response).to redirect_to(send(path)) - if message - expect(flash[:alert]).to match(/#{message}/) - end + expect(flash[:alert]).to match(/#{message}/) if message end end describe 'POST #create' do it 'requires organizer privileges' do - post :create, conference: attributes_for(:conference, - short_title: 'ExCon', organization_id: organization.id) + post :create, params: { conference: attributes_for(:conference, + short_title: 'ExCon', organization_id: organization.id) } expect(response).to redirect_to(send(path)) - if message - expect(flash[:alert]).to match(/#{message}/) - end + expect(flash[:alert]).to match(/#{message}/) if message end end end @@ -330,11 +328,9 @@ describe Admin::ConferencesController do shared_examples 'access as participant or guest' do |path, message| describe 'GET #show' do it 'requires organizer privileges' do - get :show, id: conference.short_title + get :show, params: { id: conference.short_title } expect(response).to redirect_to(send(path)) - if message - expect(flash[:alert]).to match(/#{message}/) - end + expect(flash[:alert]).to match(/#{message}/) if message end end @@ -342,21 +338,16 @@ describe Admin::ConferencesController do it 'requires organizer privileges' do get :index expect(response).to redirect_to(send(path)) - if message - expect(flash[:alert]).to match(/#{message}/) - end + expect(flash[:alert]).to match(/#{message}/) if message end end describe 'PATCH #update' do it 'requires organizer privileges' do - patch :update, id: conference.short_title, - conference: attributes_for(:conference, - short_title: 'ExCon') + patch :update, params: { id: conference.short_title, conference: attributes_for(:conference, + short_title: 'ExCon') } expect(response).to redirect_to(send(path)) - if message - expect(flash[:alert]).to match(/#{message}/) - end + expect(flash[:alert]).to match(/#{message}/) if message end end end @@ -371,7 +362,6 @@ describe Admin::ConferencesController do end describe 'guest access' do - it_behaves_like 'access as participant or guest', :new_user_session_path it_behaves_like 'access as organizer, participant or guest', :new_user_session_path end diff --git a/spec/controllers/admin/event_schedules_controller_spec.rb b/spec/controllers/admin/event_schedules_controller_spec.rb index 6c1cfedd..48d2dc71 100644 --- a/spec/controllers/admin/event_schedules_controller_spec.rb +++ b/spec/controllers/admin/event_schedules_controller_spec.rb @@ -1,11 +1,13 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::EventSchedulesController do let(:venue) { create(:venue) } let(:conference) { create(:conference, venue: venue) } let(:room) { create(:room, venue: venue) } - let(:schedule) { create(:schedule, program: conference.program)} - let(:event_schedule) { create(:event_schedule, schedule: schedule)} + let(:schedule) { create(:schedule, program: conference.program) } + let(:event_schedule) { create(:event_schedule, schedule: schedule) } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } let(:organizer) { create(:user, role_ids: organizer_role.id) } @@ -18,16 +20,16 @@ describe Admin::EventSchedulesController do describe 'POST #create' do context 'with valid attributes' do let(:create_action) do - post :create, conference_id: conference.short_title, event_schedule: + post :create, params: { conference_id: conference.short_title, event_schedule: attributes_for(:event_schedule, schedule_id: schedule.id, event_id: create(:event, program: conference.program).id, room_id: create(:room, venue: venue).id, - start_time: conference.start_date + conference.start_hour.hours) + start_time: conference.start_date + conference.start_hour.hours) } end it 'saves the event schedule to the database' do - expect{ create_action }.to change { EventSchedule.count }.by 1 + expect { create_action }.to change { EventSchedule.count }.by 1 end it 'has 200 status code' do @@ -37,18 +39,17 @@ describe Admin::EventSchedulesController do end context 'with invalid attributes' do - let(:create_action) do - post :create, conference_id: conference.short_title, event_schedule: + post :create, params: { conference_id: conference.short_title, event_schedule: attributes_for(:event_schedule, schedule_id: schedule.id, event_id: nil, room_id: nil, - start_time: nil) + start_time: nil) } end it 'does not save the event schedule to the database' do - expect{ create_action }.to_not change { EventSchedule.count } + expect { create_action }.to_not change { EventSchedule.count } end it 'has 422 status code' do @@ -61,12 +62,12 @@ describe Admin::EventSchedulesController do describe 'POST #update' do context 'with valid attributes' do before :each do - patch :update, id: event_schedule.id, conference_id: conference.short_title, event_schedule: + patch :update, params: { id: event_schedule.id, conference_id: conference.short_title, event_schedule: attributes_for(:event_schedule, schedule_id: schedule.id, event_id: create(:event, program: conference.program).id, room_id: room.id, - start_time: conference.start_date + conference.start_hour.hours) + start_time: conference.start_date + conference.start_hour.hours) } event_schedule.reload end @@ -85,15 +86,15 @@ describe Admin::EventSchedulesController do context 'with invalid attributes' do let(:update_action) do - patch :update, id: event_schedule.id, conference_id: conference.short_title, event_schedule: + patch :update, params: { id: event_schedule.id, conference_id: conference.short_title, event_schedule: attributes_for(:event_schedule, schedule_id: schedule.id, event_id: nil, room_id: nil, - start_time: nil) + start_time: nil) } end it 'does not save the event schedule to the database' do - expect{ update_action }.to_not change { event_schedule } + expect { update_action }.to_not change { event_schedule } end it 'has 422 status code' do @@ -105,11 +106,11 @@ describe Admin::EventSchedulesController do describe 'DELETE #destroy' do let(:destroy_action) do - delete :destroy, id: event_schedule.id, conference_id: conference.short_title + delete :destroy, params: { id: event_schedule.id, conference_id: conference.short_title } end it 'deletes the event schedule' do - expect{ destroy_action }.to change { EventSchedule.count }.by(-1) + expect { destroy_action }.to change { EventSchedule.count }.by(-1) end it 'has 200 status code' do diff --git a/spec/controllers/admin/events_controller_spec.rb b/spec/controllers/admin/events_controller_spec.rb index 682defce..b87f0a14 100644 --- a/spec/controllers/admin/events_controller_spec.rb +++ b/spec/controllers/admin/events_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::EventsController do @@ -16,7 +18,7 @@ describe Admin::EventsController do describe 'GET #show' do before :each do sign_in(organizer) - get :show, id: event_without_commercial.id, conference_id: conference.short_title + get :show, params: { id: event_without_commercial.id, conference_id: conference.short_title } end it 'assigns versions' do diff --git a/spec/controllers/admin/organizations_controller_spec.rb b/spec/controllers/admin/organizations_controller_spec.rb index 801cce83..3be8d50e 100644 --- a/spec/controllers/admin/organizations_controller_spec.rb +++ b/spec/controllers/admin/organizations_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::OrganizationsController do @@ -35,13 +37,13 @@ describe Admin::OrganizationsController do describe 'POST #create' do it 'does not create new organization' do expected = expect do - post :create, organization: attributes_for(:organization) + post :create, params: { organization: attributes_for(:organization) } end expected.to_not change(Organization, :count) end it 'redirects to root' do - post :create, organization: attributes_for(:organization) + post :create, params: { organization: attributes_for(:organization) } expect(flash[:alert]).to eq('You are not authorized to access this page.') expect(response).to redirect_to(root_path) @@ -51,7 +53,7 @@ describe Admin::OrganizationsController do describe 'PATCH #update' do it 'does not update and redirects to root' do old_name = organization.name - patch :update, id: organization.id, organization: attributes_for(:organization, name: 'new name') + patch :update, params: { id: organization.id, organization: attributes_for(:organization, name: 'new name') } organization.reload expect(organization.name).to eq(old_name) @@ -64,13 +66,13 @@ describe Admin::OrganizationsController do context 'for a valid organization' do it 'does not destroy a resource' do expected = expect do - delete :destroy, id: organization.id + delete :destroy, params: { id: organization.id } end expected.to_not change(Organization, :count) end it 'redirects to root' do - delete :destroy, id: organization.id + delete :destroy, params: { id: organization.id } expect(flash[:alert]).to eq('You are not authorized to access this page.') expect(response).to redirect_to(root_path) @@ -102,13 +104,13 @@ describe Admin::OrganizationsController do context 'with valid attributes' do it 'creates new organization' do expected = expect do - post :create, organization: attributes_for(:organization) + post :create, params: { organization: attributes_for(:organization) } end expected.to change { Organization.count }.by(1) end it 'redirects to index' do - post :create, organization: attributes_for(:organization) + post :create, params: { organization: attributes_for(:organization) } expect(flash[:notice]).to eq('Organization successfully created') expect(response).to redirect_to(admin_organizations_path) @@ -118,13 +120,13 @@ describe Admin::OrganizationsController do context 'with invalid attributes' do it 'does not create new organization' do expected = expect do - post :create, organization: attributes_for(:organization, name: '') + post :create, params: { organization: attributes_for(:organization, name: '') } end expected.to_not change(Organization, :count) end it 'redirects to new' do - post :create, organization: attributes_for(:organization, name: '') + post :create, params: { organization: attributes_for(:organization, name: '') } expect(flash[:error]).to eq("Name can't be blank") expect(response).to redirect_to(new_admin_organization_path) @@ -134,7 +136,7 @@ describe Admin::OrganizationsController do describe 'PATCH #update' do it 'saves and redirects to index when the attributes are valid' do - patch :update, id: organization.id, organization: attributes_for(:organization, name: 'changed name') + patch :update, params: { id: organization.id, organization: attributes_for(:organization, name: 'changed name') } organization.reload expect(organization.name).to eq('changed name') @@ -143,7 +145,7 @@ describe Admin::OrganizationsController do end it 'redirects to edit when attributes are invalid' do - patch :update, id: organization.id, organization: attributes_for(:organization, name: '') + patch :update, params: { id: organization.id, organization: attributes_for(:organization, name: '') } expect(flash[:error]).to eq("Name can't be blank") expect(response).to redirect_to(edit_admin_organization_path(organization)) @@ -154,13 +156,13 @@ describe Admin::OrganizationsController do context 'for a valid organization' do it 'should successfully destroy a resource' do expected = expect do - delete :destroy, id: organization.id + delete :destroy, params: { id: organization.id } end expected.to change { Organization.count }.by(-1) end it 'redirects to index' do - delete :destroy, id: organization.id + delete :destroy, params: { id: organization.id } expect(flash[:notice]).to eq('Organization successfully destroyed') expect(response).to redirect_to(admin_organizations_path) @@ -172,8 +174,7 @@ describe Admin::OrganizationsController do let(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) } before do - post :assign_org_admins, id: organization.id, - user: { email: user.email } + post :assign_org_admins, params: { id: organization.id, user: { email: user.email } } end it 'assigns organization_admin role' do @@ -186,8 +187,7 @@ describe Admin::OrganizationsController do let!(:org_admin_user) { create(:user, role_ids: [org_admin_role.id]) } before do - delete :unassign_org_admins, id: organization.id, - user: { email: org_admin_user.email } + delete :unassign_org_admins, params: { id: organization.id, user: { email: org_admin_user.email } } end it 'unassigns organization_admin role' do diff --git a/spec/controllers/admin/programs_controller_spec.rb b/spec/controllers/admin/programs_controller_spec.rb index 3ad98071..da739eed 100644 --- a/spec/controllers/admin/programs_controller_spec.rb +++ b/spec/controllers/admin/programs_controller_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::ProgramsController, type: :controller do - # It is necessary to use bang version of let to build roles before user let(:conference) { create(:conference) } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } @@ -10,7 +11,7 @@ describe Admin::ProgramsController, type: :controller do context 'not logged in user' do describe 'GET #show' do it 'does not render admin/programs#show' do - get :show, conference_id: conference.short_title + get :show, params: { conference_id: conference.short_title } expect(response).to redirect_to(user_session_path) end end @@ -23,7 +24,7 @@ describe Admin::ProgramsController, type: :controller do describe 'PATCH #update' do it 'redirects to admin/programs#index' do - patch :update, conference_id: conference.short_title, program: attributes_for(:program) + patch :update, params: { conference_id: conference.short_title, program: attributes_for(:program) } conference.program.reload expect(response).to redirect_to admin_conference_program_path(conference.short_title) end diff --git a/spec/controllers/admin/registration_periods_controller_spec.rb b/spec/controllers/admin/registration_periods_controller_spec.rb index fd98ce77..4620c6b9 100644 --- a/spec/controllers/admin/registration_periods_controller_spec.rb +++ b/spec/controllers/admin/registration_periods_controller_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::RegistrationPeriodsController do - # It is necessary to use bang version of let to build roles before user let(:conference) { create(:conference) } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } @@ -11,35 +12,33 @@ describe Admin::RegistrationPeriodsController do let(:participant) { create(:user) } shared_examples 'access as administration or organizer' do - before do conference.registration_period = create(:registration_period) end describe 'PATCH #update' do - context 'valid attributes' do - it 'locates the requested registration period object' do - patch :update, conference_id: conference.short_title, registration_period: attributes_for(:registration_period) + patch :update, params: { conference_id: conference.short_title, registration_period: attributes_for(:registration_period) } expect(assigns(:registration_period)).to eq(conference.registration_period) end it 'changes registration period attributes' do the_date = conference.end_date - 10 - patch :update, conference_id: conference.short_title, registration_period: - attributes_for(:registration_period, start_date: the_date) + patch :update, params: { conference_id: conference.short_title, registration_period: + attributes_for(:registration_period, start_date: the_date) } conference.reload expect(conference.registration_period.start_date.to_s).to eq(the_date.to_s) end it 'redirects to the updated registration period' do - patch :update, conference_id: conference.short_title, registration_period: - attributes_for(:registration_period) + patch :update, params: { conference_id: conference.short_title, registration_period: + attributes_for(:registration_period) } conference.reload expect(response).to redirect_to admin_conference_registration_period_path( - conference.short_title) + conference.short_title + ) end it 'sends email notification on conference registration date update' do @@ -50,10 +49,10 @@ describe Admin::RegistrationPeriodsController do start_date: Date.today, end_date: Date.today + 2.days) - patch :update, conference_id: conference.short_title, registration_period: + patch :update, params: { conference_id: conference.short_title, registration_period: attributes_for(:registration_period, start_date: Date.today + 2.days, - end_date: Date.today + 4.days) + end_date: Date.today + 4.days) } conference.reload allow(Mailbot).to receive(:conference_registration_date_update_mail).and_return(mailer) end @@ -64,41 +63,34 @@ describe Admin::RegistrationPeriodsController do context 'with valid attributes' do it 'saves the registration period to the database' do expected = expect do - post :create, - conference_id: conference.short_title, - registration_period: attributes_for(:registration_period) + post :create, params: { conference_id: conference.short_title, registration_period: attributes_for(:registration_period) } end expected.to change { RegistrationPeriod.count }.by 1 end it 'redirects to registration_periods#show' do - post :create, - conference_id: conference.short_title, - registration_period: attributes_for(:registration_period) + post :create, params: { conference_id: conference.short_title, registration_period: attributes_for(:registration_period) } expect(response).to redirect_to admin_conference_registration_period_path( - assigns[:conference].short_title) + assigns[:conference].short_title + ) end end context 'with invalid attributes' do it 'does not save the registration period to the database' do expected = expect do - post :create, - conference_id: conference.short_title, - registration_period: attributes_for(:registration_period, - start_date: nil, - end_date: nil) + post :create, params: { conference_id: conference.short_title, registration_period: attributes_for(:registration_period, + start_date: nil, + end_date: nil) } end expected.to_not change { Conference.count } end it 're-renders the new template' do - post :create, - conference_id: conference.short_title, - registration_period: attributes_for(:registration_period, - start_date: nil, - end_date: nil) + post :create, params: { conference_id: conference.short_title, registration_period: attributes_for(:registration_period, + start_date: nil, + end_date: nil) } expect(response).to be_success end end @@ -106,58 +98,56 @@ describe Admin::RegistrationPeriodsController do describe 'GET #edit' do it 'assigns the requested registration period to @registration_period' do - get :edit, conference_id: conference.short_title + get :edit, params: { conference_id: conference.short_title } expect(assigns(:registration_period)).to eq conference.registration_period end it 'renders the show template' do - get :edit, conference_id: conference.short_title + get :edit, params: { conference_id: conference.short_title } expect(response).to render_template :edit end end describe 'GET #show' do it 'assigns the requested registration period to @registration_period' do - get :show, conference_id: conference.short_title + get :show, params: { conference_id: conference.short_title } expect(assigns(:registration_period)).to eq conference.registration_period end it 'renders the show template' do - get :show, conference_id: conference.short_title + get :show, params: { conference_id: conference.short_title } expect(response).to render_template :show end end describe 'GET #new' do it 'assigns a new registration period to @registration_period' do - get :new, conference_id: conference.short_title + get :new, params: { conference_id: conference.short_title } expect(assigns(:registration_period)).to be_a_new(RegistrationPeriod) end it 'renders the :new template' do - get :new, conference_id: conference.short_title + get :new, params: { conference_id: conference.short_title } expect(response).to render_template :new end end describe 'DELETE #destroy' do it 'it deletes the registration period' do - expect { delete :destroy, conference_id: conference.short_title }.to change(RegistrationPeriod, :count).by(-1) + expect { delete :destroy, params: { conference_id: conference.short_title } }.to change(RegistrationPeriod, :count).by(-1) end it 'redirects to users#show' do - delete :destroy, conference_id: conference.short_title + delete :destroy, params: { conference_id: conference.short_title } expect(response).to redirect_to admin_conference_registration_period_path end end end describe 'organizer access' do - before(:each) do sign_in(organizer) end it_behaves_like 'access as administration or organizer' - end end diff --git a/spec/controllers/admin/roles_controller_spec.rb b/spec/controllers/admin/roles_controller_spec.rb index dcc81313..41f24ea3 100644 --- a/spec/controllers/admin/roles_controller_spec.rb +++ b/spec/controllers/admin/roles_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::RolesController do @@ -12,7 +14,7 @@ describe Admin::RolesController do describe 'GET #index' do before :each do sign_in(admin) - get :index, conference_id: conference.short_title + get :index, params: { conference_id: conference.short_title } end it 'assigns default value to selection variable' do @@ -43,9 +45,7 @@ describe Admin::RolesController do describe 'PATCH #update' do before :each do sign_in admin - patch :update, conference_id: conference.short_title, - id: 'cfp', - role: { description: 'New description for cfp role!' } + patch :update, params: { conference_id: conference.short_title, id: 'cfp', role: { description: 'New description for cfp role!' } } end it 'changes the description of the role' do @@ -56,9 +56,7 @@ describe Admin::RolesController do describe 'POST #toggle' do before :each do sign_in admin - post :toggle_user, conference_id: conference.short_title, - user: { email: 'user1@osem.io' }, - id: 'cfp' + post :toggle_user, params: { conference_id: conference.short_title, user: { email: 'user1@osem.io' }, id: 'cfp' } end context 'assigns correct values to variables' do @@ -77,17 +75,13 @@ describe Admin::RolesController do context 'adds role to user' do it 'adds second user' do - post :toggle_user, conference_id: conference.short_title, - user: { email: 'user2@osem.io' }, - id: 'cfp' + post :toggle_user, params: { conference_id: conference.short_title, user: { email: 'user2@osem.io' }, id: 'cfp' } expect(user2.roles).to eq [cfp_role] end it 'assigns second role to user' do - post :toggle_user, conference_id: conference.short_title, - user: { email: 'user1@osem.io' }, - id: 'organizer' + post :toggle_user, params: { conference_id: conference.short_title, user: { email: 'user1@osem.io' }, id: 'organizer' } expect(user1.roles).to eq [organizer_role, cfp_role] end @@ -95,23 +89,17 @@ describe Admin::RolesController do context 'removes role from user' do it 'removes role from user' do - post :toggle_user, conference_id: conference.short_title, - user: { email: 'user1@osem.io', state: 'false' }, - id: 'cfp' + post :toggle_user, params: { conference_id: conference.short_title, user: { email: 'user1@osem.io', state: 'false' }, id: 'cfp' } expect(user1.roles).to eq [] end it 'removes second role from user' do - post :toggle_user, conference_id: conference.short_title, - user: { email: 'user1@osem.io' }, - id: 'organizer' + post :toggle_user, params: { conference_id: conference.short_title, user: { email: 'user1@osem.io' }, id: 'organizer' } expect(user1.roles).to eq [organizer_role, cfp_role] - post :toggle_user, conference_id: conference.short_title, - user: { email: 'user1@osem.io', state: 'false' }, - id: 'cfp' + post :toggle_user, params: { conference_id: conference.short_title, user: { email: 'user1@osem.io', state: 'false' }, id: 'cfp' } user1.reload expect(user1.roles).to eq [organizer_role] @@ -120,15 +108,11 @@ describe Admin::RolesController do it 'does not remove role if user is the last organizer' do # Add role organizer - post :toggle_user, conference_id: conference.short_title, - user: { email: 'user1@osem.io', state: 'true' }, - id: 'organizer' + post :toggle_user, params: { conference_id: conference.short_title, user: { email: 'user1@osem.io', state: 'true' }, id: 'organizer' } expect(organizer_role.users).to eq [user1] # Try to remove role organizer, when there is only 1 user as organizer - post :toggle_user, conference_id: conference.short_title, - user: { email: 'user1@osem.io', state: 'false' }, - id: 'organizer' + post :toggle_user, params: { conference_id: conference.short_title, user: { email: 'user1@osem.io', state: 'false' }, id: 'organizer' } expect(organizer_role.users).to eq [user1] end end diff --git a/spec/controllers/admin/rooms_controller_spec.rb b/spec/controllers/admin/rooms_controller_spec.rb index dc8c3d2e..a4bf382f 100644 --- a/spec/controllers/admin/rooms_controller_spec.rb +++ b/spec/controllers/admin/rooms_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::RoomsController do @@ -10,7 +12,7 @@ describe Admin::RoomsController do before { sign_in admin } describe 'GET #index' do - before { get :index, conference_id: conference.short_title } + before { get :index, params: { conference_id: conference.short_title } } it 'assigns conference, venue and rooms variables' do expect(assigns(:conference)).to eq conference @@ -24,7 +26,7 @@ describe Admin::RoomsController do end describe 'GET #edit' do - before { get :edit, conference_id: conference.short_title, id: room.id } + before { get :edit, params: { conference_id: conference.short_title, id: room.id } } it 'renders edit template' do expect(response).to render_template('edit') @@ -36,7 +38,7 @@ describe Admin::RoomsController do end describe 'GET #new' do - before { get :new, conference_id: conference.short_title } + before { get :new, params: { conference_id: conference.short_title } } it 'renders new template' do expect(response).to render_template('new') @@ -50,7 +52,7 @@ describe Admin::RoomsController do describe 'POST #create' do context 'saves successfuly' do before do - post :create, room: attributes_for(:room), conference_id: conference.short_title + post :create, params: { room: attributes_for(:room), conference_id: conference.short_title } end it 'redirects to admin room index path' do @@ -69,7 +71,7 @@ describe Admin::RoomsController do context 'save fails' do before do allow_any_instance_of(Room).to receive(:save).and_return(false) - post :create, room: attributes_for(:room), conference_id: conference.short_title + post :create, params: { room: attributes_for(:room), conference_id: conference.short_title } end it 'renders new template' do @@ -89,9 +91,7 @@ describe Admin::RoomsController do describe 'PATCH #update' do context 'updates successfully' do before do - patch :update, room: attributes_for(:room, size: 2), - conference_id: conference.short_title, - id: room.id + patch :update, params: { room: attributes_for(:room, size: 2), conference_id: conference.short_title, id: room.id } end it 'redirects to admin room index path' do @@ -111,9 +111,7 @@ describe Admin::RoomsController do context 'update fails' do before do allow_any_instance_of(Room).to receive(:save).and_return(false) - patch :update, room: attributes_for(:room, size: 2), - conference_id: conference.short_title, - id: room.id + patch :update, params: { room: attributes_for(:room, size: 2), conference_id: conference.short_title, id: room.id } end it 'renders edit template' do @@ -133,7 +131,7 @@ describe Admin::RoomsController do describe 'DELETE #destroy' do context 'deletes successfully' do - before { delete :destroy, conference_id: conference.short_title, id: room.id } + before { delete :destroy, params: { conference_id: conference.short_title, id: room.id } } it 'redirects to admin room index path' do expect(response).to redirect_to admin_conference_venue_rooms_path(conference_id: conference.short_title) @@ -151,7 +149,7 @@ describe Admin::RoomsController do context 'delete fails' do before do allow_any_instance_of(Room).to receive(:destroy).and_return(false) - delete :destroy, conference_id: conference.short_title, id: room.id + delete :destroy, params: { conference_id: conference.short_title, id: room.id } end it 'redirects to admin room index path' do diff --git a/spec/controllers/admin/schedules_controller_spec.rb b/spec/controllers/admin/schedules_controller_spec.rb index 7ba5860e..87bf19f4 100644 --- a/spec/controllers/admin/schedules_controller_spec.rb +++ b/spec/controllers/admin/schedules_controller_spec.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::SchedulesController do let(:conference) { create(:conference) } - let(:schedule) { create(:schedule, program: conference.program)} + let(:schedule) { create(:schedule, program: conference.program) } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } let(:organizer) { create(:user, role_ids: organizer_role.id) } @@ -14,27 +16,28 @@ describe Admin::SchedulesController do describe 'GET #index' do it 'renders the index template' do - get :index, conference_id: conference.short_title + get :index, params: { conference_id: conference.short_title } expect(response).to render_template :index end end describe 'POST #create' do - let(:create_action){ post :create, conference_id: conference.short_title } + let(:create_action) { post :create, params: { conference_id: conference.short_title } } it 'saves the schedule to the database' do - expect{ create_action }.to change { Schedule.count }.by 1 + expect { create_action }.to change { Schedule.count }.by 1 end it 'redirects to schedules#show' do create_action expect(response).to redirect_to admin_conference_schedule_path( - conference.short_title, assigns[:schedule]) + conference.short_title, assigns[:schedule] + ) end end describe 'GET #show' do - let(:show_action){ get :show, id: schedule.id, conference_id: conference.short_title } + let(:show_action) { get :show, params: { id: schedule.id, conference_id: conference.short_title } } it 'assigns the requested schedule to schedule' do show_action @@ -48,10 +51,10 @@ describe Admin::SchedulesController do end describe 'DELETE #destroy' do - let(:destroy_action){ delete :destroy, id: schedule.id, conference_id: conference.short_title } + let(:destroy_action) { delete :destroy, params: { id: schedule.id, conference_id: conference.short_title } } it 'deletes the schedule' do - expect{ destroy_action }.to change { Schedule.count }.by(-1) + expect { destroy_action }.to change { Schedule.count }.by(-1) end it 'redirects to schedules#index' do diff --git a/spec/controllers/admin/sponsorship_levels_controller_spec.rb b/spec/controllers/admin/sponsorship_levels_controller_spec.rb index 058c703c..48fe03b4 100644 --- a/spec/controllers/admin/sponsorship_levels_controller_spec.rb +++ b/spec/controllers/admin/sponsorship_levels_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::SponsorshipLevelsController do @@ -9,7 +11,7 @@ describe Admin::SponsorshipLevelsController do before { sign_in admin } describe 'GET #index' do - before { get :index, conference_id: conference.short_title } + before { get :index, params: { conference_id: conference.short_title } } it 'assigns conference and sponsorship_levels variables' do expect(assigns(:conference)).to eq conference @@ -22,7 +24,7 @@ describe Admin::SponsorshipLevelsController do end describe 'GET #edit' do - before { get :edit, conference_id: conference.short_title, id: sponsorship_level.id } + before { get :edit, params: { conference_id: conference.short_title, id: sponsorship_level.id } } it 'renders edit template' do expect(response).to render_template('edit') @@ -34,7 +36,7 @@ describe Admin::SponsorshipLevelsController do end describe 'GET #new' do - before { get :new, conference_id: conference.short_title } + before { get :new, params: { conference_id: conference.short_title } } it 'renders new template' do expect(response).to render_template('new') @@ -48,8 +50,7 @@ describe Admin::SponsorshipLevelsController do describe 'POST #create' do context 'saves successfuly' do before(:each, run: true) do - post :create, sponsorship_level: attributes_for(:sponsorship_level), - conference_id: conference.short_title + post :create, params: { sponsorship_level: attributes_for(:sponsorship_level), conference_id: conference.short_title } end it 'redirects to admin sponsorship_level index path', run: true do @@ -62,17 +63,15 @@ describe Admin::SponsorshipLevelsController do it 'creates new sponsorship_level' do expect do - post :create, sponsorship_level: attributes_for(:sponsorship_level), - conference_id: conference.short_title - end.to change{ conference.sponsorship_levels.count }.from(0).to(1) + post :create, params: { sponsorship_level: attributes_for(:sponsorship_level), conference_id: conference.short_title } + end.to change { conference.sponsorship_levels.count }.from(0).to(1) end end context 'save fails' do before do allow_any_instance_of(SponsorshipLevel).to receive(:save).and_return(false) - post :create, sponsorship_level: attributes_for(:sponsorship_level), - conference_id: conference.short_title + post :create, params: { sponsorship_level: attributes_for(:sponsorship_level), conference_id: conference.short_title } end it 'renders new template' do @@ -92,9 +91,7 @@ describe Admin::SponsorshipLevelsController do describe 'PATCH #update' do context 'updates successfully' do before do - patch :update, sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'), - conference_id: conference.short_title, - id: sponsorship_level.id + patch :update, params: { sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'), conference_id: conference.short_title, id: sponsorship_level.id } end it 'redirects to admin sponsorship_level index path' do @@ -114,9 +111,7 @@ describe Admin::SponsorshipLevelsController do context 'update fails' do before do allow_any_instance_of(SponsorshipLevel).to receive(:save).and_return(false) - patch :update, sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'), - conference_id: conference.short_title, - id: sponsorship_level.id + patch :update, params: { sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'), conference_id: conference.short_title, id: sponsorship_level.id } end it 'renders edit template' do @@ -137,7 +132,7 @@ describe Admin::SponsorshipLevelsController do describe 'DELETE #destroy' do context 'deletes successfully' do before(:each, run: true) do - delete :destroy, conference_id: conference.short_title, id: sponsorship_level.id + delete :destroy, params: { conference_id: conference.short_title, id: sponsorship_level.id } end it 'redirects to admin sponsorship_level index path', run: true do @@ -151,15 +146,15 @@ describe Admin::SponsorshipLevelsController do it 'deletes the sponsorship_level' do sponsorship_level expect do - delete :destroy, conference_id: conference.short_title, id: sponsorship_level.id - end.to change{ conference.sponsorship_levels.count }.from(1).to(0) + delete :destroy, params: { conference_id: conference.short_title, id: sponsorship_level.id } + end.to change { conference.sponsorship_levels.count }.from(1).to(0) end end context 'delete fails' do before do allow_any_instance_of(SponsorshipLevel).to receive(:destroy).and_return(false) - delete :destroy, conference_id: conference.short_title, id: sponsorship_level.id + delete :destroy, params: { conference_id: conference.short_title, id: sponsorship_level.id } end it 'redirects to admin sponsorship_level index path' do @@ -180,7 +175,7 @@ describe Admin::SponsorshipLevelsController do before do sponsorship_level @second_sponsorship_level = create(:sponsorship_level, conference: conference) - patch :up, conference_id: conference.short_title, id: @second_sponsorship_level.id + patch :up, params: { conference_id: conference.short_title, id: @second_sponsorship_level.id } end it 'moves sponsorship_level up by one position' do @@ -195,7 +190,7 @@ describe Admin::SponsorshipLevelsController do before do sponsorship_level @second_sponsorship_level = create(:sponsorship_level, conference: conference) - patch :down, conference_id: conference.short_title, id: sponsorship_level.id + patch :down, params: { conference_id: conference.short_title, id: sponsorship_level.id } end it 'moves sponsorship_level down by one position' do diff --git a/spec/controllers/admin/targets_controller_spec.rb b/spec/controllers/admin/targets_controller_spec.rb index 2b8b5dd4..37c17e31 100644 --- a/spec/controllers/admin/targets_controller_spec.rb +++ b/spec/controllers/admin/targets_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::TargetsController, type: :controller do @@ -9,7 +11,7 @@ describe Admin::TargetsController, type: :controller do before { sign_in admin } describe 'GET #index' do - before { get :index, conference_id: conference.short_title } + before { get :index, params: { conference_id: conference.short_title } } it 'renders index template' do expect(response).to render_template('index') @@ -22,7 +24,7 @@ describe Admin::TargetsController, type: :controller do end describe 'GET #new' do - before { get :new, conference_id: conference.short_title } + before { get :new, params: { conference_id: conference.short_title } } it 'renders new template' do expect(response).to render_template('new') @@ -36,7 +38,7 @@ describe Admin::TargetsController, type: :controller do describe 'POST #create' do context 'saves successfuly' do before do - post :create, target: attributes_for(:target), conference_id: conference.short_title + post :create, params: { target: attributes_for(:target), conference_id: conference.short_title } end it 'redirects to admin target index path' do @@ -55,7 +57,7 @@ describe Admin::TargetsController, type: :controller do context 'save fails' do before do allow_any_instance_of(Target).to receive(:save).and_return(false) - post :create, target: attributes_for(:target), conference_id: conference.short_title + post :create, params: { target: attributes_for(:target), conference_id: conference.short_title } end it 'renders new template' do @@ -73,7 +75,7 @@ describe Admin::TargetsController, type: :controller do end describe 'GET #edit' do - before { get :edit, conference_id: conference.short_title, id: target.id } + before { get :edit, params: { conference_id: conference.short_title, id: target.id } } it 'renders edit template' do expect(response).to render_template('edit') @@ -87,9 +89,7 @@ describe Admin::TargetsController, type: :controller do describe 'PATCH #update' do context 'updates successfully' do before do - patch :update, target: attributes_for(:target, target_count: 2), - conference_id: conference.short_title, - id: target.id + patch :update, params: { target: attributes_for(:target, target_count: 2), conference_id: conference.short_title, id: target.id } end it 'redirects to admin target index path' do @@ -109,9 +109,7 @@ describe Admin::TargetsController, type: :controller do context 'update fails' do before do allow_any_instance_of(Target).to receive(:save).and_return(false) - patch :update, target: attributes_for(:target, target_count: 2), - conference_id: conference.short_title, - id: target.id + patch :update, params: { target: attributes_for(:target, target_count: 2), conference_id: conference.short_title, id: target.id } end it 'renders edit template' do @@ -130,7 +128,7 @@ describe Admin::TargetsController, type: :controller do describe 'DELETE #destroy' do context 'deletes successfully' do - before { delete :destroy, conference_id: conference.short_title, id: target.id } + before { delete :destroy, params: { conference_id: conference.short_title, id: target.id } } it 'redirects to admin target index path' do expect(response).to redirect_to admin_conference_targets_path(conference_id: conference.short_title) @@ -148,7 +146,7 @@ describe Admin::TargetsController, type: :controller do context 'delete fails' do before do allow_any_instance_of(Target).to receive(:destroy).and_return(false) - delete :destroy, conference_id: conference.short_title, id: target.id + delete :destroy, params: { conference_id: conference.short_title, id: target.id } end it 'redirects to admin target index path' do diff --git a/spec/controllers/admin/ticket_scannings_controller_spec.rb b/spec/controllers/admin/ticket_scannings_controller_spec.rb index 2eb2e4ed..83909a28 100644 --- a/spec/controllers/admin/ticket_scannings_controller_spec.rb +++ b/spec/controllers/admin/ticket_scannings_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::TicketScanningsController do @@ -16,13 +18,13 @@ describe Admin::TicketScanningsController do describe 'POST #create' do it 'does not create new ticket scanning' do expected = expect do - post :create, physical_ticket_id: physical_ticket.token + post :create, params: { physical_ticket_id: physical_ticket.token } end expected.to_not change(TicketScanning, :count) end it 'redirects to root' do - post :create, physical_ticket_id: physical_ticket.token + post :create, params: { physical_ticket_id: physical_ticket.token } expect(flash[:alert]).to eq('You are not authorized to access this page.') expect(response).to redirect_to(root_path) end @@ -37,13 +39,13 @@ describe Admin::TicketScanningsController do context 'with valid physical_ticket' do it 'creates new ticket scanning' do expected = expect do - post :create, physical_ticket_id: physical_ticket.token + post :create, params: { physical_ticket_id: physical_ticket.token } end expected.to change { TicketScanning.count }.by(1) end it 'redirects to index' do - post :create, physical_ticket_id: physical_ticket.token + post :create, params: { physical_ticket_id: physical_ticket.token } expect(flash[:notice]).to eq("Ticket with token #{physical_ticket.token} successfully scanned.") expect(response).to redirect_to(conferences_path) end @@ -52,7 +54,7 @@ describe Admin::TicketScanningsController do context 'with Invalid physical_ticket' do it 'raises exception' do expected = expect do - post :create, physical_ticket_id: 'XXXX' + post :create, params: { physical_ticket_id: 'XXXX' } end expected.to raise_exception(ActiveRecord::RecordNotFound) end diff --git a/spec/controllers/admin/tracks_controller_spec.rb b/spec/controllers/admin/tracks_controller_spec.rb index 03511ce1..2fb6df8d 100644 --- a/spec/controllers/admin/tracks_controller_spec.rb +++ b/spec/controllers/admin/tracks_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::TracksController do @@ -15,7 +17,7 @@ describe Admin::TracksController do describe 'GET #index' do before :each do - get :index, conference_id: conference.short_title + get :index, params: { conference_id: conference.short_title } end it 'assigns @tracks with the correct values' do @@ -31,7 +33,7 @@ describe Admin::TracksController do describe 'GET #show' do before :each do - get :show, conference_id: conference.short_title, id: track.short_name + get :show, params: { conference_id: conference.short_title, id: track.short_name } end it 'assigns the correct track' do @@ -45,7 +47,7 @@ describe Admin::TracksController do describe 'GET #new' do before :each do - get :new, conference_id: conference.short_title + get :new, params: { conference_id: conference.short_title } end it 'assigns a new track with the correct conference' do @@ -62,7 +64,7 @@ describe Admin::TracksController do describe 'POST #create' do context 'saves successfuly' do before :each do - post :create, track: attributes_for(:track), conference_id: conference.short_title + post :create, params: { track: attributes_for(:track), conference_id: conference.short_title } end it 'assigns a new track with the correct conference' do @@ -92,7 +94,7 @@ describe Admin::TracksController do context 'save fails' do before :each do allow_any_instance_of(Track).to receive(:save).and_return(false) - post :create, track: attributes_for(:track, short_name: 'my_track'), conference_id: conference.short_title + post :create, params: { track: attributes_for(:track, short_name: 'my_track'), conference_id: conference.short_title } end it 'assigns a new track with the correct conference' do @@ -117,7 +119,7 @@ describe Admin::TracksController do describe 'GET #edit' do before :each do - get :edit, conference_id: conference.short_title, id: track.short_name + get :edit, params: { conference_id: conference.short_title, id: track.short_name } end it 'assigns the correct track' do @@ -132,9 +134,7 @@ describe Admin::TracksController do describe 'PATCH #update' do context 'updates successfully' do before :each do - patch :update, track: attributes_for(:track, color: '#FF0000'), - conference_id: conference.short_title, - id: track.short_name + patch :update, params: { track: attributes_for(:track, color: '#FF0000'), conference_id: conference.short_title, id: track.short_name } end it 'assigns the correct track' do @@ -158,9 +158,7 @@ describe Admin::TracksController do context 'update fails' do before :each do allow_any_instance_of(Track).to receive(:save).and_return(false) - patch :update, track: attributes_for(:track, color: '#FF0000'), - conference_id: conference.short_title, - id: track.short_name + patch :update, params: { track: attributes_for(:track, color: '#FF0000'), conference_id: conference.short_title, id: track.short_name } end it 'assigns the correct track' do @@ -185,7 +183,7 @@ describe Admin::TracksController do describe 'DELETE #destroy' do context 'deletes successfully' do before :each do - delete :destroy, conference_id: conference.short_title, id: track.short_name + delete :destroy, params: { conference_id: conference.short_title, id: track.short_name } end it 'redirects to admin tracks index path' do @@ -204,7 +202,7 @@ describe Admin::TracksController do context 'delete fails' do before :each do allow_any_instance_of(Track).to receive(:destroy).and_return(false) - delete :destroy, conference_id: conference.short_title, id: track.short_name + delete :destroy, params: { conference_id: conference.short_title, id: track.short_name } end it 'assigns the correct track' do @@ -234,7 +232,7 @@ describe Admin::TracksController do context 'toggles successfully' do before :each do - patch :toggle_cfp_inclusion, conference_id: conference.short_title, id: self_organized_track.short_name, format: :js + patch :toggle_cfp_inclusion, params: { conference_id: conference.short_title, id: self_organized_track.short_name, format: :js } self_organized_track.reload end @@ -254,7 +252,7 @@ describe Admin::TracksController do context 'save fails' do before :each do allow_any_instance_of(Track).to receive(:save).and_return(false) - patch :toggle_cfp_inclusion, conference_id: conference.short_title, id: self_organized_track.short_name, format: :js + patch :toggle_cfp_inclusion, params: { conference_id: conference.short_title, id: self_organized_track.short_name, format: :js } self_organized_track.reload end @@ -280,7 +278,7 @@ describe Admin::TracksController do context 'toggles successfully' do before :each do - patch :toggle_cfp_inclusion, conference_id: conference.short_title, id: self_organized_track.short_name, format: :js + patch :toggle_cfp_inclusion, params: { conference_id: conference.short_title, id: self_organized_track.short_name, format: :js } self_organized_track.reload end @@ -300,7 +298,7 @@ describe Admin::TracksController do context 'save fails' do before :each do allow_any_instance_of(Track).to receive(:save).and_return(false) - patch :toggle_cfp_inclusion, conference_id: conference.short_title, id: self_organized_track.short_name, format: :js + patch :toggle_cfp_inclusion, params: { conference_id: conference.short_title, id: self_organized_track.short_name, format: :js } self_organized_track.reload end @@ -323,7 +321,7 @@ describe Admin::TracksController do before :each do self_organized_track.state = 'canceled' self_organized_track.save! - patch :restart, conference_id: conference.short_title, id: self_organized_track.short_name + patch :restart, params: { conference_id: conference.short_title, id: self_organized_track.short_name } self_organized_track.reload end @@ -342,7 +340,7 @@ describe Admin::TracksController do describe 'PATCH #to_accept' do before :each do - patch :to_accept, conference_id: conference.short_title, id: self_organized_track.short_name + patch :to_accept, params: { conference_id: conference.short_title, id: self_organized_track.short_name } self_organized_track.reload end @@ -362,7 +360,7 @@ describe Admin::TracksController do describe 'PATCH #accept' do shared_examples 'fails to accept' do before :each do - patch :accept, conference_id: conference.short_title, id: self_organized_track.short_name + patch :accept, params: { conference_id: conference.short_title, id: self_organized_track.short_name } end it 'assigns the correct track' do @@ -380,7 +378,7 @@ describe Admin::TracksController do context 'has start_date, end_date and room' do before :each do - patch :accept, conference_id: conference.short_title, id: self_organized_track.short_name + patch :accept, params: { conference_id: conference.short_title, id: self_organized_track.short_name } self_organized_track.reload end @@ -470,7 +468,7 @@ describe Admin::TracksController do before :each do self_organized_track.state = 'accepted' self_organized_track.save! - patch :confirm, conference_id: conference.short_title, id: self_organized_track.short_name + patch :confirm, params: { conference_id: conference.short_title, id: self_organized_track.short_name } self_organized_track.reload end @@ -489,7 +487,7 @@ describe Admin::TracksController do describe 'PATCH #to_reject' do before :each do - patch :to_reject, conference_id: conference.short_title, id: self_organized_track.short_name + patch :to_reject, params: { conference_id: conference.short_title, id: self_organized_track.short_name } self_organized_track.reload end @@ -508,7 +506,7 @@ describe Admin::TracksController do describe 'PATCH #reject' do before :each do - patch :reject, conference_id: conference.short_title, id: self_organized_track.short_name + patch :reject, params: { conference_id: conference.short_title, id: self_organized_track.short_name } self_organized_track.reload end @@ -529,7 +527,7 @@ describe Admin::TracksController do before :each do self_organized_track.state = 'confirmed' self_organized_track.save! - patch :cancel, conference_id: conference.short_title, id: self_organized_track.short_name + patch :cancel, params: { conference_id: conference.short_title, id: self_organized_track.short_name } self_organized_track.reload end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index c0ba43ba..68e6d0c9 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::UsersController do let(:admin) { create(:admin) } @@ -21,12 +23,12 @@ describe Admin::UsersController do describe 'PATCH #toggle_confirmation' do it 'confirms user' do user_to_confirm = create(:user, email: 'unconfirmed_user@osem.io', confirmed_at: nil) - patch :toggle_confirmation, id: user_to_confirm.id, user: { to_confirm: 'true' } + patch :toggle_confirmation, params: { id: user_to_confirm.id, user: { to_confirm: 'true' } } user_to_confirm.reload expect(user_to_confirm.confirmed?).to eq true end it 'undo confirmation of user' do - patch :toggle_confirmation, id: user.id, user: { to_confirm: 'false' } + patch :toggle_confirmation, params: { id: user.id, user: { to_confirm: 'false' } } user.reload expect(user.confirmed?).to eq false end @@ -34,7 +36,7 @@ describe Admin::UsersController do describe 'PATCH #update' do context 'valid attributes' do before :each do - patch :update, id: user.id, user: { name: 'new name', email: 'new_email@osem.io' } + patch :update, params: { id: user.id, user: { name: 'new name', email: 'new_email@osem.io' } } end it 'locates requested @user' do @@ -42,8 +44,9 @@ 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 @@ -64,7 +67,7 @@ describe Admin::UsersController do describe 'POST #create' do context 'saves successfuly' do before do - post :create, user: attributes_for(:user) + post :create, params: { user: attributes_for(:user) } end it 'redirects to admin users index path' do @@ -83,7 +86,7 @@ describe Admin::UsersController do context 'save fails' do before do allow_any_instance_of(User).to receive(:save).and_return(false) - post :create, user: attributes_for(:user) + post :create, params: { user: attributes_for(:user) } end it 'renders new template' do @@ -96,8 +99,8 @@ describe Admin::UsersController do it 'does not create new user' do expect do - post :create, user: attributes_for(:user) - end.not_to change{ Event.count } + post :create, params: { user: attributes_for(:user) } + end.not_to change { Event.count } end end end diff --git a/spec/controllers/admin/versions_controller_spec.rb b/spec/controllers/admin/versions_controller_spec.rb index f04bc33d..3bfb315d 100644 --- a/spec/controllers/admin/versions_controller_spec.rb +++ b/spec/controllers/admin/versions_controller_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' describe Admin::VersionsController do - let!(:conference) { create(:conference, short_title: 'exampletitle', description: 'Example Description') } let(:admin) { create(:admin) } let(:role_organizer) { conference.roles.find_by(name: 'organizer') } @@ -15,8 +16,8 @@ describe Admin::VersionsController do end it 'reverts all changes for update actions' do - conference.update_attributes(short_title: 'testtitle', description: 'Some random text') - get :revert_object, id: PaperTrail::Version.last.id + conference.update(short_title: 'testtitle', description: 'Some random text') + get :revert_object, params: { id: PaperTrail::Version.last.id } conference.reload expect(conference.short_title).to eq 'exampletitle' expect(conference.description).to eq 'Example Description' @@ -25,14 +26,14 @@ describe Admin::VersionsController do it 'shows correct flash on trying to revert create event of a deleted object' do creation_version_id = conference.program.event_types.first.versions.first.id conference.program.event_types.first.destroy - get :revert_object, id: creation_version_id + get :revert_object, params: { id: creation_version_id } expect(flash[:error]).to match('The item is already in the state that you are trying to revert it back to') end it 'reverting deletion of object creates it again' do conference.program.event_types.first.destroy event_types_count = conference.program.event_types.count - get :revert_object, id: PaperTrail::Version.last.id + get :revert_object, params: { id: PaperTrail::Version.last.id } conference.reload expect(PaperTrail::Version.last.event).to eq 'create' expect(conference.program.event_types.count).to eq(event_types_count + 1) @@ -40,14 +41,14 @@ describe Admin::VersionsController do it 'reverting creation of object deletes it ' do create(:lodging, conference: conference) - get :revert_object, id: PaperTrail::Version.last.id + get :revert_object, params: { id: PaperTrail::Version.last.id } expect(PaperTrail::Version.last.event).to eq 'destroy' expect(Lodging.count).to eq 0 end it 'reverting creation of conference is not permitted' do conference_count_before = Conference.count - get :revert_object, id: conference.versions.first.id + get :revert_object, params: { id: conference.versions.first.id } expect(flash[:alert]).to eq 'You are not authorized to access this page.' expect(Conference.count).to eq(conference_count_before) end @@ -59,40 +60,40 @@ describe Admin::VersionsController do end it 'reverts specified change for update actions' do - conference.update_attributes(short_title: 'testtitle', description: 'Some random text') - get :revert_attribute, id: PaperTrail::Version.last.id, attribute: 'short_title' + conference.update(short_title: 'testtitle', description: 'Some random text') + get :revert_attribute, params: { id: PaperTrail::Version.last.id, attribute: 'short_title' } conference.reload expect(conference.short_title).to eq 'exampletitle' expect(conference.description).to eq 'Some random text' end it 'shows correct flash on trying to revert to the current state' do - conference.update_attributes(short_title: 'testtitle', description: 'Some random text') - conference.update_attributes(short_title: 'exampletitle') - get :revert_attribute, id: PaperTrail::Version.all[-2].id, attribute: 'short_title' + conference.update(short_title: 'testtitle', description: 'Some random text') + conference.update(short_title: 'exampletitle') + get :revert_attribute, params: { id: PaperTrail::Version.all[-2].id, attribute: 'short_title' } expect(flash[:error]).to match('The item is already in the state that you are trying to revert it back to') expect(conference.short_title).to eq 'exampletitle' end it 'fails on trying to revert deleted object' do - conference.program.event_types.first.update_attributes(title: 'New Event Title') + conference.program.event_types.first.update(title: 'New Event Title') conference.program.event_types.first.destroy - get :revert_attribute, id: PaperTrail::Version.all[-2].id, attribute: 'title' + get :revert_attribute, params: { id: PaperTrail::Version.all[-2].id, attribute: 'title' } conference.reload expect(flash[:alert]).to eq 'You are not authorized to access this page.' end it 'fails on trying to revert creation event' do create(:lodging, conference: conference) - get :revert_attribute, id: PaperTrail::Version.last.id, attribute: 'name' + get :revert_attribute, params: { id: PaperTrail::Version.last.id, attribute: 'name' } expect(flash[:alert]).to eq 'You are not authorized to access this page.' end it 'revert fails when attribute is invalid' do - conference.update_attributes(short_title: 'testtitle', description: 'Some random text') + conference.update(short_title: 'testtitle', description: 'Some random text') before_conference_title = conference.title # Note: even though title is a valid attribute of conference, it was not updated in the change we are trying to revert - get :revert_attribute, id: PaperTrail::Version.last.id, attribute: 'title' + get :revert_attribute, params: { id: PaperTrail::Version.last.id, attribute: 'title' } conference.reload expect(conference.short_title).to eq 'testtitle' expect(conference.description).to eq 'Some random text' @@ -105,7 +106,7 @@ describe Admin::VersionsController do it 'raises error if user is not of any role' do user = create(:user) sign_in user - get :index, conference_id: conference.short_title + get :index, params: { conference_id: conference.short_title } expect(flash[:alert]).to match('You are not authorized to access this page.') end @@ -113,19 +114,19 @@ describe Admin::VersionsController do before :each do @user = create(:user) - conference.update_attributes(short_title: 'testtitle', description: 'Some random text') + conference.update(short_title: 'testtitle', description: 'Some random text') @version_organizer = PaperTrail::Version.last create(:cfp, program: conference.program) @version_cfp = PaperTrail::Version.last registration = create(:registration, conference: conference) - registration.update_attributes(attended: true) + registration.update(attended: true) @version_info_desk = PaperTrail::Version.last end it 'when user has role cfp' do @user.roles = [role_cfp] sign_in @user - get :index, conference_id: conference.short_title + get :index, params: { conference_id: conference.short_title } expect(assigns(:versions).include?(@version_cfp)).to eq true expect(assigns(:versions).include?(@version_organizer)).to eq false @@ -134,7 +135,7 @@ describe Admin::VersionsController do it 'when user has role info_desk' do @user.roles = [role_info_desk] sign_in @user - get :index, conference_id: conference.short_title + get :index, params: { conference_id: conference.short_title } expect(assigns(:versions).include?(@version_info_desk)).to eq true expect(assigns(:versions).include?(@version_organizer)).to eq false @@ -144,7 +145,7 @@ describe Admin::VersionsController do it 'when user has role organizer' do @user.roles = [role_organizer] sign_in @user - get :index, conference_id: conference.short_title + get :index, params: { conference_id: conference.short_title } expect(assigns(:versions).include?(@version_organizer)).to eq true expect(assigns(:versions).include?(@version_cfp)).to eq true diff --git a/spec/controllers/api/v1/conferences_controller_spec.rb b/spec/controllers/api/v1/conferences_controller_spec.rb index a64a1adc..6e819e99 100644 --- a/spec/controllers/api/v1/conferences_controller_spec.rb +++ b/spec/controllers/api/v1/conferences_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Api::V1::ConferencesController do @@ -26,7 +28,7 @@ describe Api::V1::ConferencesController do describe 'GET #show' do before(:each) do - get :show, id: 'conf_two', format: :json + get :show, params: { id: 'conf_two', format: :json } @json = JSON.parse(response.body)['conferences'] end diff --git a/spec/controllers/api/v1/events_controller_spec.rb b/spec/controllers/api/v1/events_controller_spec.rb index daee0002..877451ce 100644 --- a/spec/controllers/api/v1/events_controller_spec.rb +++ b/spec/controllers/api/v1/events_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Api::V1::EventsController do @@ -8,7 +10,6 @@ describe Api::V1::EventsController do describe 'GET #index' do context 'without conference scope' do it 'returns all confirmed events' do - get :index, format: :json json = JSON.parse(response.body)['events'] expect(response).to be_success @@ -21,8 +22,7 @@ describe Api::V1::EventsController do context 'with conference scope' do it 'returns all confirmed events of conference' do - - get :index, conference_id: conference.short_title, format: :json + get :index, params: { conference_id: conference.short_title, format: :json } json = JSON.parse(response.body)['events'] expect(response).to be_success diff --git a/spec/controllers/api/v1/rooms_controller_spec.rb b/spec/controllers/api/v1/rooms_controller_spec.rb index 48a8db98..5843c641 100644 --- a/spec/controllers/api/v1/rooms_controller_spec.rb +++ b/spec/controllers/api/v1/rooms_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Api::V1::RoomsController do @@ -9,7 +11,6 @@ describe Api::V1::RoomsController do describe 'GET #index' do context 'without conference scope' do it 'returns all rooms' do - get :index, format: :json json = JSON.parse(response.body)['rooms'] @@ -23,8 +24,7 @@ describe Api::V1::RoomsController do context 'with conference scope' do it 'returns all rooms of conference' do - - get :index, conference_id: conference.short_title, format: :json + get :index, params: { conference_id: conference.short_title, format: :json } json = JSON.parse(response.body)['rooms'] expect(response).to be_success diff --git a/spec/controllers/api/v1/speakers_controller_spec.rb b/spec/controllers/api/v1/speakers_controller_spec.rb index 539baeaf..e51f4293 100644 --- a/spec/controllers/api/v1/speakers_controller_spec.rb +++ b/spec/controllers/api/v1/speakers_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Api::V1::SpeakersController do @@ -16,7 +18,6 @@ describe Api::V1::SpeakersController do context 'without conference scope' do it 'returns all speakers' do - get :index, format: :json json = JSON.parse(response.body)['speakers'] expect(response).to be_success @@ -28,8 +29,7 @@ describe Api::V1::SpeakersController do context 'with conference scope' do it 'returns all speakers of conference' do - - get :index, conference_id: conference.short_title, format: :json + get :index, params: { conference_id: conference.short_title, format: :json } json = JSON.parse(response.body)['speakers'] expect(response).to be_success diff --git a/spec/controllers/api/v1/tracks_controller_spec.rb b/spec/controllers/api/v1/tracks_controller_spec.rb index a1424ce3..24ccf80d 100644 --- a/spec/controllers/api/v1/tracks_controller_spec.rb +++ b/spec/controllers/api/v1/tracks_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Api::V1::TracksController do @@ -8,7 +10,6 @@ describe Api::V1::TracksController do describe 'GET #index' do context 'without conference scope' do it 'returns all tracks' do - get :index, format: :json json = JSON.parse(response.body)['tracks'] @@ -22,8 +23,7 @@ describe Api::V1::TracksController do context 'with conference scope' do it 'returns all rooms of conference' do - - get :index, conference_id: conference.short_title, format: :json + get :index, params: { conference_id: conference.short_title, format: :json } json = JSON.parse(response.body)['tracks'] expect(response).to be_success diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 4d1c2eab..6f02a7c1 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -1,10 +1,11 @@ +# frozen_string_literal: true + require 'spec_helper' describe ApplicationController, type: :controller do let(:conference) { create(:conference) } describe 'user is signed in' do - describe 'as admin' do let(:admin) { create(:admin) } before { sign_in(admin) } @@ -31,16 +32,13 @@ describe ApplicationController, type: :controller do end end end - end - end describe ApplicationController, type: :request do let(:conference) { create(:conference) } describe 'Skylight link' do - around do |example| original_value = ENV['SKYLIGHT_PUBLIC_DASHBOARD_URL'] example.run @@ -70,7 +68,5 @@ describe ApplicationController, type: :request do expect(response.body).to_not match(/skylight/i) end end - end - end diff --git a/spec/controllers/booths_controller_spec.rb b/spec/controllers/booths_controller_spec.rb index 56f3b9d9..55969416 100644 --- a/spec/controllers/booths_controller_spec.rb +++ b/spec/controllers/booths_controller_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' describe BoothsController do - let(:user) { create(:user) } let(:conference) { create(:conference) } let(:booth) { create(:booth, title: 'Title', conference: conference) } @@ -13,7 +14,7 @@ describe BoothsController do end describe 'GET index' do - before { get :index, conference_id: conference.short_title } + before { get :index, params: { conference_id: conference.short_title } } it 'assigns attributes for booths' do expect(assigns(:booths)).to eq([booth]) @@ -25,7 +26,7 @@ describe BoothsController do end describe 'GET #new' do - before { get :new, conference_id: conference.short_title } + before { get :new, params: { conference_id: conference.short_title } } it 'assigns attributes for booths' do expect(assigns(:booth)).to be_a_new(Booth) @@ -38,7 +39,7 @@ describe BoothsController do describe 'POST #create' do context 'successfully created' do - before { post :create, booth: attributes_for(:booth), conference_id: conference.short_title } + before { post :create, params: { booth: attributes_for(:booth), conference_id: conference.short_title } } it 'creates a new booth' do expect(Booth.count).to_not eq(0) @@ -58,11 +59,11 @@ describe BoothsController do end context 'create action fails' do - before { post :create, booth: attributes_for(:booth, title: ''), conference_id: conference.short_title } + before { post :create, params: { booth: attributes_for(:booth, title: ''), conference_id: conference.short_title } } it 'does not create any record' do expected = expect do - post :create, booth: attributes_for(:booth, title: ''), conference_id: conference.short_title + post :create, params: { booth: attributes_for(:booth, title: ''), conference_id: conference.short_title } end expected.to_not change(Booth, :count) end @@ -78,7 +79,7 @@ describe BoothsController do end describe 'GET #edit' do - before { get :edit, id: booth.id, conference_id: conference.short_title } + before { get :edit, params: { id: booth.id, conference_id: conference.short_title } } it 'renders edit template' do expect(response).to render_template('edit') @@ -91,7 +92,7 @@ describe BoothsController do describe 'PATCH #update' do context 'updates suchessfully' do - before { patch :update, id: booth.id, booth: attributes_for(:booth, title: 'different'), conference_id: conference.short_title } + before { patch :update, params: { id: booth.id, booth: attributes_for(:booth, title: 'different'), conference_id: conference.short_title } } it 'redirects to booth index path' do expect(response).to redirect_to conference_booths_path diff --git a/spec/controllers/conference_registration_controller_spec.rb b/spec/controllers/conference_registration_controller_spec.rb index a6f1503c..20a13b28 100644 --- a/spec/controllers/conference_registration_controller_spec.rb +++ b/spec/controllers/conference_registration_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ConferenceRegistrationsController, type: :controller do @@ -11,7 +13,7 @@ describe ConferenceRegistrationsController, type: :controller do before :each do sign_in send(user) if user stub_const('ENV', ENV.to_hash.merge('OSEM_ICHAIN_ENABLED' => ichain)) - get :new, conference_id: conference.short_title + get :new, params: { conference_id: conference.short_title } end it 'redirects' do @@ -27,7 +29,7 @@ describe ConferenceRegistrationsController, type: :controller do before :each do sign_in send(user) if user stub_const('ENV', ENV.to_hash.merge('OSEM_ICHAIN_ENABLED' => ichain)) - get :new, conference_id: conference.short_title + get :new, params: { conference_id: conference.short_title } end it 'user variable exists' do @@ -229,7 +231,7 @@ describe ConferenceRegistrationsController, type: :controller do context 'successful request' do before do - get :show, conference_id: conference.short_title + get :show, params: { conference_id: conference.short_title } end it 'assigns variables' do @@ -248,7 +250,7 @@ describe ConferenceRegistrationsController, type: :controller do @purchased_ticket = create(:ticket_purchase, conference: conference, user: user, ticket: @ticket) - get :show, conference_id: conference.short_title + get :show, params: { conference_id: conference.short_title } end it 'does not assign price of purchased tickets to total_price and purchased tickets to tickets without payment' do @@ -258,7 +260,7 @@ describe ConferenceRegistrationsController, type: :controller do context 'user has not purchased any ticket' do before do - get :show, conference_id: conference.short_title + get :show, params: { conference_id: conference.short_title } end it 'assigns 0 dollars to total_price and empty array to tickets variables' do @@ -271,7 +273,7 @@ describe ConferenceRegistrationsController, type: :controller do describe 'GET #edit' do before do @registration = create(:registration, conference: conference, user: user) - get :edit, conference_id: conference.short_title + get :edit, params: { conference_id: conference.short_title } end it 'assigns conference and registration variable' do @@ -289,13 +291,12 @@ describe ConferenceRegistrationsController, type: :controller do @registration = create(:registration, conference: conference, user: user, - arrival: Date.new(2014, 04, 25)) + arrival: Date.new(2014, 0o4, 25)) end context 'updates successfully' do before do - patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 29)), - conference_id: conference.short_title + patch :update, params: { registration: attributes_for(:registration, arrival: Date.new(2014, 0o4, 29)), conference_id: conference.short_title } end it 'redirects to registration show path' do @@ -308,15 +309,14 @@ describe ConferenceRegistrationsController, type: :controller do it 'updates the registration' do @registration.reload - expect(@registration.arrival).to eq Date.new(2014, 04, 29) + expect(@registration.arrival).to eq Date.new(2014, 0o4, 29) end end context 'update fails' do before do allow_any_instance_of(Registration).to receive(:update_attributes).and_return(false) - patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 27)), - conference_id: conference.short_title + patch :update, params: { registration: attributes_for(:registration, arrival: Date.new(2014, 0o4, 27)), conference_id: conference.short_title } end it 'renders edit template' do @@ -329,7 +329,7 @@ describe ConferenceRegistrationsController, type: :controller do it 'does not update the registration' do @registration.reload - expect(@registration.arrival).to eq Date.new(2014, 04, 25) + expect(@registration.arrival).to eq Date.new(2014, 0o4, 25) end end end @@ -341,7 +341,7 @@ describe ConferenceRegistrationsController, type: :controller do context 'deletes successfully' do before(:each, run: true) do - delete :destroy, conference_id: conference.short_title + delete :destroy, params: { conference_id: conference.short_title } end it 'redirects to root path', run: true do @@ -354,15 +354,15 @@ describe ConferenceRegistrationsController, type: :controller do it 'deletes the registration' do expect do - delete :destroy, conference_id: conference.short_title - end.to change{ Registration.count }.from(2).to(1) + delete :destroy, params: { conference_id: conference.short_title } + end.to change { Registration.count }.from(2).to(1) end end context 'delete fails' do before do allow_any_instance_of(Registration).to receive(:destroy).and_return(false) - delete :destroy, conference_id: conference.short_title + delete :destroy, params: { conference_id: conference.short_title } end it 'redirects to registration show path' do diff --git a/spec/controllers/conferences_controller_spec.rb b/spec/controllers/conferences_controller_spec.rb index cdbebf9f..de0fe32f 100644 --- a/spec/controllers/conferences_controller_spec.rb +++ b/spec/controllers/conferences_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ConferencesController do @@ -15,12 +17,12 @@ describe ConferencesController do describe 'GET #show' do context 'conference made public' do it 'assigns the requested conference to conference' do - get :show, id: conference.short_title + get :show, params: { id: conference.short_title } expect(assigns(:conference)).to eq conference end it 'renders the show template' do - get :show, id: conference.short_title + get :show, params: { id: conference.short_title } expect(response).to render_template :show end end @@ -46,5 +48,4 @@ describe ConferencesController do expect(response.response_code).to eq(200) end end - end diff --git a/spec/controllers/confirmations_controller_spec.rb b/spec/controllers/confirmations_controller_spec.rb index 1db675b3..60675d47 100644 --- a/spec/controllers/confirmations_controller_spec.rb +++ b/spec/controllers/confirmations_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ConfirmationsController do @@ -9,7 +11,7 @@ describe ConfirmationsController do context 'user is not signed in' do it 'confirms and signs in user' do - get :show, confirmation_token: user.confirmation_token + get :show, params: { confirmation_token: user.confirmation_token } user.reload expect(user.confirmed?).to eq true expect(controller.current_user).to eq user @@ -20,7 +22,7 @@ describe ConfirmationsController do before { sign_in user } it 'confirms user' do - get :show, confirmation_token: user.confirmation_token + get :show, params: { confirmation_token: user.confirmation_token } user.reload expect(user.confirmed?).to eq true end diff --git a/spec/controllers/organizations_controller_spec.rb b/spec/controllers/organizations_controller_spec.rb index eb0109a1..e719f823 100644 --- a/spec/controllers/organizations_controller_spec.rb +++ b/spec/controllers/organizations_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe OrganizationsController do @@ -35,7 +37,7 @@ describe OrganizationsController do describe 'GET #conferences' do before :each do - get :conferences, id: organization.id + get :conferences, params: { id: organization.id } end it 'loads the organization' do diff --git a/spec/controllers/physical_ticket_controller_spec.rb b/spec/controllers/physical_ticket_controller_spec.rb index 476a1717..7b2a02c4 100644 --- a/spec/controllers/physical_ticket_controller_spec.rb +++ b/spec/controllers/physical_ticket_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe PhysicalTicketsController do @@ -9,7 +11,7 @@ describe PhysicalTicketsController do describe 'GET #show' do before :each do sign_in user - get :show, id: physical_ticket.token, conference_id: conference.short_title + get :show, params: { id: physical_ticket.token, conference_id: conference.short_title } end it 'assigns ticket_layout' do diff --git a/spec/controllers/proposals_controller_spec.rb b/spec/controllers/proposals_controller_spec.rb index 9b01e55f..5177d784 100644 --- a/spec/controllers/proposals_controller_spec.rb +++ b/spec/controllers/proposals_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ProposalsController do @@ -11,7 +13,7 @@ describe ProposalsController do before do # We allow new proposal only if program has open cfp create(:cfp, program: conference.program) - get :new, conference_id: conference.short_title + get :new, params: { conference_id: conference.short_title } end it 'assigns user and url variables' do @@ -29,9 +31,7 @@ describe ProposalsController do before { create(:cfp, program: conference.program) } it 'assigns url variables' do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title, - user: attributes_for(:user) + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: attributes_for(:user) } expect(assigns(:url)).to eq '/conferences/lama101/program/proposals' end @@ -39,9 +39,7 @@ describe ProposalsController do describe 'user related actions' do before do @new_user = attributes_for(:user) - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title, - user: @new_user + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: @new_user } end it 'creates new user' do @@ -56,9 +54,7 @@ describe ProposalsController do context 'creates proposal successfully' do before(:each, run: true) do @new_user = attributes_for(:user) - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title, - user: @new_user + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: @new_user } end it 'assigns event variable', run: true do @@ -84,19 +80,15 @@ describe ProposalsController do it 'creates new event' do expect do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title, - user: attributes_for(:user) - end.to change{ Event.count }.by 1 + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: attributes_for(:user) } + end.to change { Event.count }.by 1 end end context 'proposal save fails' do before(:each, run: true) do allow_any_instance_of(Event).to receive(:save).and_return(false) - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title, - user: attributes_for(:user) + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: attributes_for(:user) } end it 'renders new template', run: true do @@ -110,10 +102,8 @@ describe ProposalsController do it 'does not create new proposal' do allow_any_instance_of(Event).to receive(:save).and_return(false) expect do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title, - user: attributes_for(:user) - end.not_to change{ Event.count } + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: attributes_for(:user) } + end.not_to change { Event.count } end end end @@ -123,25 +113,19 @@ describe ProposalsController do it 'does not create new user' do expect do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title, - user: attributes_for(:user) + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: attributes_for(:user) } end.not_to change { User.count } end it 'does not create new event' do expect do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title, - user: attributes_for(:user) + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: attributes_for(:user) } end.not_to change { Event.count } end describe 'response' do before do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title, - user: attributes_for(:user) + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: attributes_for(:user) } end it 'renders new template' do @@ -162,7 +146,7 @@ describe ProposalsController do end describe 'GET #index' do - before { get :index, conference_id: conference.short_title } + before { get :index, params: { conference_id: conference.short_title } } it 'assigns conference, program and events variables' do expect(assigns(:conference)).to eq conference @@ -177,7 +161,7 @@ describe ProposalsController do describe 'GET #show' do before do - get :show, conference_id: conference.short_title, id: event.id + get :show, params: { conference_id: conference.short_title, id: event.id } end it 'assigns event variable' do @@ -193,7 +177,7 @@ describe ProposalsController do before do # We allow new proposal only if program has open cfp create(:cfp, program: conference.program) - get :new, conference_id: conference.short_title + get :new, params: { conference_id: conference.short_title } end it 'assigns user and url variables' do @@ -208,7 +192,7 @@ describe ProposalsController do describe 'GET #edit' do before do - get :edit, conference_id: conference.short_title, id: event.id + get :edit, params: { conference_id: conference.short_title, id: event.id } end it 'assigns event and url variables' do @@ -226,15 +210,13 @@ describe ProposalsController do before { create(:cfp, program: conference.program) } it 'assigns url variables' do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title } expect(assigns(:url)).to eq '/conferences/lama101/program/proposals' end context 'creates proposal successfully' do before(:each, run: true) do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title } end it 'assigns event variable', run: true do @@ -260,17 +242,15 @@ describe ProposalsController do it 'creates new event' do expect do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title - end.to change{ Event.count }.by 1 + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title } + end.to change { Event.count }.by 1 end end context 'proposal save fails' do before(:each, run: true) do allow_any_instance_of(Event).to receive(:save).and_return(false) - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title } end it 'renders new template', run: true do @@ -284,27 +264,21 @@ describe ProposalsController do it 'does not create new proposal' do allow_any_instance_of(Event).to receive(:save).and_return(false) expect do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - conference_id: conference.short_title - end.not_to change{ Event.count } + post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title } + end.not_to change { Event.count } end end end describe 'PATCH #update' do - it 'assigns url variable' do - patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), - conference_id: conference.short_title, - id: event.id + patch :update, params: { event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), conference_id: conference.short_title, id: event.id } expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}" end context 'updates successfully' do before do - patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), - conference_id: conference.short_title, - id: event.id + patch :update, params: { event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), conference_id: conference.short_title, id: event.id } end it 'updates the proposal' do @@ -324,9 +298,7 @@ describe ProposalsController do context 'update fails' do before do allow_any_instance_of(Event).to receive(:save).and_return(false) - patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), - conference_id: conference.short_title, - id: event.id + patch :update, params: { event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), conference_id: conference.short_title, id: event.id } end it 'does not update the proposal' do @@ -345,15 +317,14 @@ describe ProposalsController do end describe 'PATCH #withdraw' do - it 'assigns url variable' do - patch :withdraw, conference_id: conference.short_title, id: event.id + patch :withdraw, params: { conference_id: conference.short_title, id: event.id } expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}" end context 'withdraws successfully' do before do - patch :withdraw, conference_id: conference.short_title, id: event.id + patch :withdraw, params: { conference_id: conference.short_title, id: event.id } end it 'changes state of event to withdrawn' do @@ -374,7 +345,7 @@ describe ProposalsController do before do request.env['HTTP_REFERER'] = '/' allow_any_instance_of(Event).to receive(:withdraw).and_raise(Transitions::InvalidTransition) - patch :withdraw, conference_id: conference.short_title, id: event.id + patch :withdraw, params: { conference_id: conference.short_title, id: event.id } end it 'does not withdraw event' do @@ -394,7 +365,7 @@ describe ProposalsController do context 'event save fails' do before do allow_any_instance_of(Event).to receive(:save).and_return(false) - patch :withdraw, conference_id: conference.short_title, id: event.id + patch :withdraw, params: { conference_id: conference.short_title, id: event.id } end it 'does not withdraw event' do @@ -413,7 +384,7 @@ describe ProposalsController do end describe 'PATCH #confirm' do - before { event.update_attributes(state: 'unconfirmed') } + before { event.update(state: 'unconfirmed') } context 'confirmed successfully' do describe 'when require_registration is set' do @@ -421,7 +392,7 @@ describe ProposalsController do event.require_registration = true event.max_attendees = nil event.save! - patch :confirm, conference_id: conference.short_title, id: event.id + patch :confirm, params: { conference_id: conference.short_title, id: event.id } end it 'assigns url variable' do @@ -435,7 +406,7 @@ describe ProposalsController do end describe 'general actions' do - before { patch :confirm, conference_id: conference.short_title, id: event.id } + before { patch :confirm, params: { conference_id: conference.short_title, id: event.id } } it 'assigns url variable' do expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}" @@ -450,7 +421,7 @@ describe ProposalsController do context 'user has registered for the conference' do before do create(:registration, conference: conference, user: event.submitter) - patch :confirm, conference_id: conference.short_title, id: event.id + patch :confirm, params: { conference_id: conference.short_title, id: event.id } end it 'redirects to proposal index path' do @@ -464,7 +435,7 @@ describe ProposalsController do context 'user has not registered for the conference' do before do - patch :confirm, conference_id: conference.short_title, id: event.id + patch :confirm, params: { conference_id: conference.short_title, id: event.id } end it 'redirects to new registration path' do @@ -481,7 +452,7 @@ describe ProposalsController do before do request.env['HTTP_REFERER'] = '/' allow_any_instance_of(Event).to receive(:confirm).and_raise(Transitions::InvalidTransition) - patch :confirm, conference_id: conference.short_title, id: event.id + patch :confirm, params: { conference_id: conference.short_title, id: event.id } end it 'does not confirm event' do @@ -499,9 +470,9 @@ describe ProposalsController do context 'event save fails' do before do - event.update_attributes(state: 'unconfirmed') + event.update(state: 'unconfirmed') allow_any_instance_of(Event).to receive(:save).and_return(false) - patch :confirm, conference_id: conference.short_title, id: event.id + patch :confirm, params: { conference_id: conference.short_title, id: event.id } end it 'does not confirm event' do @@ -519,16 +490,16 @@ describe ProposalsController do end describe 'PATCH #restart' do - before { event.update_attributes(state: 'withdrawn') } + before { event.update(state: 'withdrawn') } it 'assigns url variable' do - patch :restart, conference_id: conference.short_title, id: event.id + patch :restart, params: { conference_id: conference.short_title, id: event.id } expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}" end context 'resubmits successfully' do before do - patch :restart, conference_id: conference.short_title, id: event.id + patch :restart, params: { conference_id: conference.short_title, id: event.id } end it 'changes state of event to new' do @@ -548,7 +519,7 @@ describe ProposalsController do context 'event resubmission fails' do before do allow_any_instance_of(Event).to receive(:restart).and_raise(Transitions::InvalidTransition) - patch :restart, conference_id: conference.short_title, id: event.id + patch :restart, params: { conference_id: conference.short_title, id: event.id } end it 'does not change state of event to new' do @@ -568,7 +539,7 @@ describe ProposalsController do context 'event save fails' do before do allow_any_instance_of(Event).to receive(:save).and_return(false) - patch :restart, conference_id: conference.short_title, id: event.id + patch :restart, params: { conference_id: conference.short_title, id: event.id } end it 'does not change state of event to new' do diff --git a/spec/controllers/schedules_controller_spec.rb b/spec/controllers/schedules_controller_spec.rb index 6ff4875c..4c80adff 100644 --- a/spec/controllers/schedules_controller_spec.rb +++ b/spec/controllers/schedules_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe SchedulesController do @@ -11,13 +13,13 @@ describe SchedulesController do create(:event_scheduled, program: conference.program) create(:event_scheduled, program: conference.program) - get :show, conference_id: conference.short_title, format: :xml + get :show, params: { conference_id: conference.short_title, format: :xml } end it 'assigns variables' do expect(assigns(:conference)).to eq conference expect(assigns(:events_xml)).to eq conference.program.selected_event_schedules.map(&:event) - .group_by{ |event| event.time.to_date } + .group_by { |event| event.time.to_date } end it 'has 200 status code' do diff --git a/spec/controllers/subscriptions_controller_spec.rb b/spec/controllers/subscriptions_controller_spec.rb index ac20a34b..dcc964a7 100644 --- a/spec/controllers/subscriptions_controller_spec.rb +++ b/spec/controllers/subscriptions_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe SubscriptionsController do @@ -7,7 +9,7 @@ describe SubscriptionsController do describe 'POST #create' do context 'when user is a guest' do it 'redirects to sign in page' do - post :create, conference_id: conference.short_title + post :create, params: { conference_id: conference.short_title } expect(response).to redirect_to new_user_session_path end end @@ -18,17 +20,17 @@ describe SubscriptionsController do end it 'redirects to home page' do - post :create, conference_id: conference.short_title + post :create, params: { conference_id: conference.short_title } expect(response).to redirect_to root_path end it 'shows success message in flash notice' do - post :create, conference_id: conference.short_title + post :create, params: { conference_id: conference.short_title } expect(flash[:notice]).to match("You have subscribed to receive email notifications for #{conference.title}") end it 'subscribes user to conference' do - post :create, conference_id: conference.short_title + post :create, params: { conference_id: conference.short_title } expect(user.subscriptions.pluck(:conference_id)).to include(conference.id) end end @@ -37,17 +39,17 @@ describe SubscriptionsController do describe 'DELETE #destroy' do before(:each) do sign_in(user) - post :create, conference_id: conference.short_title + post :create, params: { conference_id: conference.short_title } end it 'redirects to home page' do - delete :destroy, conference_id: conference.short_title + delete :destroy, params: { conference_id: conference.short_title } expect(response).to redirect_to root_path end it 'shows success message in flash notice' do - delete :destroy, conference_id: conference.short_title - expect(flash[:notice]).to match("You have unsubscribed and you will not be receiving email notifications for #{conference.title}.") + delete :destroy, params: { conference_id: conference.short_title } + expect(flash[:notice]).to match("You have unsubscribed and you will not be receiving email notifications for #{conference.title}.") end end end diff --git a/spec/controllers/tracks_controller_spec.rb b/spec/controllers/tracks_controller_spec.rb index a555dba8..73cba633 100644 --- a/spec/controllers/tracks_controller_spec.rb +++ b/spec/controllers/tracks_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe TracksController do @@ -13,7 +15,7 @@ describe TracksController do describe 'GET #index' do before :each do - get :index, conference_id: conference.short_title + get :index, params: { conference_id: conference.short_title } end it 'assigns @tracks with the correct values' do @@ -29,7 +31,7 @@ describe TracksController do describe 'GET #show' do before :each do - get :show, conference_id: conference.short_title, id: self_organized_track.short_name + get :show, params: { conference_id: conference.short_title, id: self_organized_track.short_name } end it 'assigns the correct track' do @@ -43,7 +45,7 @@ describe TracksController do describe 'GET #new' do before :each do - get :new, conference_id: conference.short_title + get :new, params: { conference_id: conference.short_title } end it 'assigns a new track with the correct conference' do @@ -60,7 +62,7 @@ describe TracksController do describe 'POST #create' do context 'saves successfuly' do before :each do - post :create, track: attributes_for(:track, :self_organized, short_name: 'my_track'), conference_id: conference.short_title + post :create, params: { track: attributes_for(:track, :self_organized, short_name: 'my_track'), conference_id: conference.short_title } end it 'redirects to tracks index path' do @@ -86,7 +88,7 @@ describe TracksController do context 'save fails' do before :each do allow_any_instance_of(Track).to receive(:save).and_return(false) - post :create, track: attributes_for(:track, :self_organized, short_name: 'my_track'), conference_id: conference.short_title + post :create, params: { track: attributes_for(:track, :self_organized, short_name: 'my_track'), conference_id: conference.short_title } end it 'assigns a new track with the correct conference' do @@ -111,7 +113,7 @@ describe TracksController do describe 'GET #edit' do before :each do - get :edit, conference_id: conference.short_title, id: self_organized_track.short_name + get :edit, params: { conference_id: conference.short_title, id: self_organized_track.short_name } end it 'assigns the correct track' do @@ -126,9 +128,7 @@ describe TracksController do describe 'PATCH #update' do context 'updates successfully' do before :each do - patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'), - conference_id: conference.short_title, - id: self_organized_track.short_name + patch :update, params: { track: attributes_for(:track, :self_organized, color: '#FF0000'), conference_id: conference.short_title, id: self_organized_track.short_name } end it 'assigns the correct track' do @@ -152,9 +152,7 @@ describe TracksController do context 'update fails' do before :each do allow_any_instance_of(Track).to receive(:save).and_return(false) - patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'), - conference_id: conference.short_title, - id: self_organized_track.short_name + patch :update, params: { track: attributes_for(:track, :self_organized, color: '#FF0000'), conference_id: conference.short_title, id: self_organized_track.short_name } end it 'assigns the correct track' do @@ -180,7 +178,7 @@ describe TracksController do before :each do self_organized_track.state = 'withdrawn' self_organized_track.save! - patch :restart, conference_id: conference.short_title, id: self_organized_track.short_name + patch :restart, params: { conference_id: conference.short_title, id: self_organized_track.short_name } self_organized_track.reload end @@ -201,7 +199,7 @@ describe TracksController do before :each do self_organized_track.state = 'accepted' self_organized_track.save! - patch :confirm, conference_id: conference.short_title, id: self_organized_track.short_name + patch :confirm, params: { conference_id: conference.short_title, id: self_organized_track.short_name } self_organized_track.reload end @@ -222,7 +220,7 @@ describe TracksController do before :each do self_organized_track.state = 'confirmed' self_organized_track.save! - patch :withdraw, conference_id: conference.short_title, id: self_organized_track.short_name + patch :withdraw, params: { conference_id: conference.short_title, id: self_organized_track.short_name } self_organized_track.reload end diff --git a/spec/controllers/users/omniauth_callbacks_controller_spec.rb b/spec/controllers/users/omniauth_callbacks_controller_spec.rb index 7204fe33..c5281085 100644 --- a/spec/controllers/users/omniauth_callbacks_controller_spec.rb +++ b/spec/controllers/users/omniauth_callbacks_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Users::OmniauthCallbacksController do @@ -14,17 +16,17 @@ end def stub_env_for_omniauth request.env['devise.mapping'] = Devise.mappings[:user] env = OmniAuth::AuthHash.new( - provider: 'google', - uid: 'google-test-uid-1', - info: { - name: 'google user', - email: nil, - username: 'user_google' - }, - credentials: { - token: 'google_mock_token', - secret: 'google_mock_secret' - } + provider: 'google', + uid: 'google-test-uid-1', + info: { + name: 'google user', + email: nil, + username: 'user_google' + }, + credentials: { + token: 'google_mock_token', + secret: 'google_mock_secret' + } ) request.env['omniauth.auth'] = env allow(@controller).to receive(:env).and_return(env) diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index e46e134c..c2010e89 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe UsersController do @@ -6,7 +8,7 @@ describe UsersController do describe 'GET #show' do before :each do - get :show, id: user.id + get :show, params: { id: user.id } end it 'renders show template' do @@ -33,7 +35,7 @@ describe UsersController do describe 'GET #edit' do it 'assigns the right value to @user' do sign_in user - get :edit, id: user.id + get :edit, params: { id: user.id } expect(assigns(:user)).to eq user end end @@ -42,7 +44,7 @@ describe UsersController do context 'with valid attributes' do before :each do sign_in user - patch :update, id: user.id, user: attributes_for(:user, name: 'My Test Name') + patch :update, params: { id: user.id, user: attributes_for(:user, name: 'My Test Name') } user.reload end diff --git a/spec/factories/answer.rb b/spec/factories/answer.rb index 367ba3a9..f2c69c32 100644 --- a/spec/factories/answer.rb +++ b/spec/factories/answer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/booth_request.rb b/spec/factories/booth_request.rb index fba0cace..02f21c41 100644 --- a/spec/factories/booth_request.rb +++ b/spec/factories/booth_request.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :booth_request do booth user role 'responsible' - end end diff --git a/spec/factories/booths.rb b/spec/factories/booths.rb index 1ac3ff87..eff90c44 100644 --- a/spec/factories/booths.rb +++ b/spec/factories/booths.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :booth do title { Faker::Hipster.sentence } diff --git a/spec/factories/campaigns.rb b/spec/factories/campaigns.rb index 5c04a6d4..dc745487 100644 --- a/spec/factories/campaigns.rb +++ b/spec/factories/campaigns.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/cfps.rb b/spec/factories/cfps.rb index ea59a8c1..d7932e2d 100644 --- a/spec/factories/cfps.rb +++ b/spec/factories/cfps.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/comments.rb b/spec/factories/comments.rb index a424e23b..736ba0ba 100644 --- a/spec/factories/comments.rb +++ b/spec/factories/comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/commercials.rb b/spec/factories/commercials.rb index 7fa052a7..00404b36 100644 --- a/spec/factories/commercials.rb +++ b/spec/factories/commercials.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb index d0f11d19..7447b36c 100644 --- a/spec/factories/conferences.rb +++ b/spec/factories/conferences.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do @@ -31,7 +33,7 @@ FactoryGirl.define do # Contact/Program is created by Conference callbacks conference.contact.destroy conference.contact = create(:contact, conference: conference) - conference.program.update_attributes(schedule_public: true) + conference.program.update(schedule_public: true) create(:cfp, program: conference.program) create_list(:track, 2, program: conference.program) diff --git a/spec/factories/contacts.rb b/spec/factories/contacts.rb index 9168f22b..ac3bccc1 100644 --- a/spec/factories/contacts.rb +++ b/spec/factories/contacts.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :contact do social_tag { SecureRandom.urlsafe_base64(4) } diff --git a/spec/factories/difficulty_levels.rb b/spec/factories/difficulty_levels.rb index 7a1e8da5..9c147830 100644 --- a/spec/factories/difficulty_levels.rb +++ b/spec/factories/difficulty_levels.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :difficulty_level do title 'Example Difficulty Level' diff --git a/spec/factories/email_settings.rb b/spec/factories/email_settings.rb index d10a6b51..db8a1480 100644 --- a/spec/factories/email_settings.rb +++ b/spec/factories/email_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/event_schedule.rb b/spec/factories/event_schedule.rb index a72e3745..208f7e29 100644 --- a/spec/factories/event_schedule.rb +++ b/spec/factories/event_schedule.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do @@ -8,10 +10,10 @@ FactoryGirl.define do unless (venue = program.conference.venue) venue = create(:venue, conference: program.conference) end - (event_schedule.room = create(:room, venue: venue)) unless event_schedule.room.present? - (event_schedule.start_time = program.conference.start_date + program.conference.start_hour.hours) unless event_schedule.start_time.present? - unless event_schedule.schedule.present? - unless program.selected_schedule.present? + (event_schedule.room = create(:room, venue: venue)) if event_schedule.room.blank? + (event_schedule.start_time = program.conference.start_date + program.conference.start_hour.hours) if event_schedule.start_time.blank? + if event_schedule.schedule.blank? + if program.selected_schedule.blank? schedule = create(:schedule, program: program) program.schedules << schedule program.selected_schedule = schedule diff --git a/spec/factories/event_types.rb b/spec/factories/event_types.rb index 5686254d..f2a282b1 100644 --- a/spec/factories/event_types.rb +++ b/spec/factories/event_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do @@ -9,5 +11,4 @@ FactoryGirl.define do color '#ffffff' program end - end diff --git a/spec/factories/event_users.rb b/spec/factories/event_users.rb index 5d1574a9..f0830243 100644 --- a/spec/factories/event_users.rb +++ b/spec/factories/event_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/events.rb b/spec/factories/events.rb index 731c774e..37fbc454 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do @@ -22,9 +24,7 @@ FactoryGirl.define do event.commercials << build(:event_commercial, commercialable: event) event.difficulty_level = build(:difficulty_level, program: event.program) event.track = build(:track, program: event.program) - unless event.program.conference.venue - create(:venue, conference: event.program.conference) - end + create(:venue, conference: event.program.conference) unless event.program.conference.venue event.comment_threads << build(:comment, commentable: event) end diff --git a/spec/factories/events_registrations.rb b/spec/factories/events_registrations.rb index 8fd7286c..84012f57 100644 --- a/spec/factories/events_registrations.rb +++ b/spec/factories/events_registrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/lodgings.rb b/spec/factories/lodgings.rb index a4bbf73c..42d02c0b 100644 --- a/spec/factories/lodgings.rb +++ b/spec/factories/lodgings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/openid.rb b/spec/factories/openid.rb index 6950c718..60dcf29f 100644 --- a/spec/factories/openid.rb +++ b/spec/factories/openid.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/organizations.rb b/spec/factories/organizations.rb index f6331873..8b10893b 100644 --- a/spec/factories/organizations.rb +++ b/spec/factories/organizations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :organization do sequence(:name) { |n| "#{Faker::Company.name} #{n}" } diff --git a/spec/factories/payments.rb b/spec/factories/payments.rb index 4d4d3c39..71a7adff 100644 --- a/spec/factories/payments.rb +++ b/spec/factories/payments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :payment do user diff --git a/spec/factories/physical_ticket.rb b/spec/factories/physical_ticket.rb index 8b4f2a0e..0356657f 100644 --- a/spec/factories/physical_ticket.rb +++ b/spec/factories/physical_ticket.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :physical_ticket do ticket_purchase diff --git a/spec/factories/programs.rb b/spec/factories/programs.rb index e3c20153..c6345088 100644 --- a/spec/factories/programs.rb +++ b/spec/factories/programs.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/qanswer.rb b/spec/factories/qanswer.rb index 136b5655..962392a1 100644 --- a/spec/factories/qanswer.rb +++ b/spec/factories/qanswer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/question.rb b/spec/factories/question.rb index 5a2a58e5..310e61b9 100644 --- a/spec/factories/question.rb +++ b/spec/factories/question.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/question_type.rb b/spec/factories/question_type.rb index aeb77096..15a942b9 100644 --- a/spec/factories/question_type.rb +++ b/spec/factories/question_type.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/registration.rb b/spec/factories/registration.rb index fb79cb4d..1cdb297d 100644 --- a/spec/factories/registration.rb +++ b/spec/factories/registration.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/registration_periods.rb b/spec/factories/registration_periods.rb index bb775aa9..333c29d0 100644 --- a/spec/factories/registration_periods.rb +++ b/spec/factories/registration_periods.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/resource.rb b/spec/factories/resource.rb index 83045e9e..4848f09d 100644 --- a/spec/factories/resource.rb +++ b/spec/factories/resource.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :resource do name { 'Resource' } diff --git a/spec/factories/roles.rb b/spec/factories/roles.rb index 67d85233..a2997a91 100644 --- a/spec/factories/roles.rb +++ b/spec/factories/roles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :role do name 'my role' diff --git a/spec/factories/rooms.rb b/spec/factories/rooms.rb index 7347b95d..7e3ebe65 100644 --- a/spec/factories/rooms.rb +++ b/spec/factories/rooms.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :room do diff --git a/spec/factories/schedule.rb b/spec/factories/schedule.rb index e1c9dc2f..8a5635d9 100644 --- a/spec/factories/schedule.rb +++ b/spec/factories/schedule.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/splashpages.rb b/spec/factories/splashpages.rb index 752a36f3..80c9f0f6 100644 --- a/spec/factories/splashpages.rb +++ b/spec/factories/splashpages.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/sponsors.rb b/spec/factories/sponsors.rb index 5d531991..f8edf4a6 100644 --- a/spec/factories/sponsors.rb +++ b/spec/factories/sponsors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do @@ -9,7 +11,7 @@ FactoryGirl.define do sponsorship_level after(:create) do |sponsor| - File.open("spec/support/logos/#{1 + rand(13)}.png") do |file| + File.open("spec/support/logos/#{rand(1..13)}.png") do |file| sponsor.picture = file end sponsor.save! diff --git a/spec/factories/sponsorship_levels.rb b/spec/factories/sponsorship_levels.rb index 72db7493..6b8a4da9 100644 --- a/spec/factories/sponsorship_levels.rb +++ b/spec/factories/sponsorship_levels.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/subscriptions.rb b/spec/factories/subscriptions.rb index 0816b70f..169a45d7 100644 --- a/spec/factories/subscriptions.rb +++ b/spec/factories/subscriptions.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :subscription do user conference end - end diff --git a/spec/factories/targets.rb b/spec/factories/targets.rb index 9d65f2ba..8318b081 100644 --- a/spec/factories/targets.rb +++ b/spec/factories/targets.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/ticket_purchases.rb b/spec/factories/ticket_purchases.rb index bee365cf..9b339ed9 100644 --- a/spec/factories/ticket_purchases.rb +++ b/spec/factories/ticket_purchases.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :ticket_purchase do user diff --git a/spec/factories/ticket_scanning.rb b/spec/factories/ticket_scanning.rb index 540d1fd0..df18fc80 100644 --- a/spec/factories/ticket_scanning.rb +++ b/spec/factories/ticket_scanning.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :ticket_scanning do physical_ticket diff --git a/spec/factories/tickets.rb b/spec/factories/tickets.rb index c4bb1539..ba623044 100644 --- a/spec/factories/tickets.rb +++ b/spec/factories/tickets.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :ticket do title { "#{Faker::Hipster.word} Ticket" } diff --git a/spec/factories/tracks.rb b/spec/factories/tracks.rb index 097a5452..eda41a11 100644 --- a/spec/factories/tracks.rb +++ b/spec/factories/tracks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :track do name { Faker::Commerce.department(2, true) } diff --git a/spec/factories/users.rb b/spec/factories/users.rb index e2e78c16..1e3ffdea 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl # It is a feature of our app that first signed up user is admin. This property @@ -54,5 +56,4 @@ FactoryGirl.define do factory :user_xss, parent: :user do biography '
' end - end diff --git a/spec/factories/vdays.rb b/spec/factories/vdays.rb index 7d7c2976..724e6cb1 100644 --- a/spec/factories/vdays.rb +++ b/spec/factories/vdays.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :vday do day { Time.zone.today } description 'Lorem Ipsum dolsum' conference end - end diff --git a/spec/factories/venues.rb b/spec/factories/venues.rb index 92c149cc..a240f951 100644 --- a/spec/factories/venues.rb +++ b/spec/factories/venues.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :venue do diff --git a/spec/factories/visits.rb b/spec/factories/visits.rb index 3a03b203..145e919d 100644 --- a/spec/factories/visits.rb +++ b/spec/factories/visits.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do diff --git a/spec/factories/votes.rb b/spec/factories/votes.rb index 12ede741..6fe973d9 100644 --- a/spec/factories/votes.rb +++ b/spec/factories/votes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :vote do event diff --git a/spec/factories/vpositions.rb b/spec/factories/vpositions.rb index 6bfcc769..2885ee2f 100644 --- a/spec/factories/vpositions.rb +++ b/spec/factories/vpositions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryGirl.define do factory :vposition do title 'Example Volunteer Position' @@ -8,5 +10,4 @@ FactoryGirl.define do vposition.vdays << build(:vday, conference: vposition.conference) end end - end diff --git a/spec/features/base_controller_spec.rb b/spec/features/base_controller_spec.rb index 1f75f81b..57d5be94 100644 --- a/spec/features/base_controller_spec.rb +++ b/spec/features/base_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature 'BaseController' do diff --git a/spec/features/campaign_spec.rb b/spec/features/campaign_spec.rb index c2fa8de6..3eb852bd 100644 --- a/spec/features/campaign_spec.rb +++ b/spec/features/campaign_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' feature Campaign do - let!(:conference) { create(:conference, short_title: 'osc14') } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } diff --git a/spec/features/cfp_ability_spec.rb b/spec/features/cfp_ability_spec.rb index 7229ab8d..910205c0 100644 --- a/spec/features/cfp_ability_spec.rb +++ b/spec/features/cfp_ability_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' feature 'Has correct abilities' do - let(:organization) { create(:organization) } let(:conference) { create(:full_conference, organization: organization) } let(:role_cfp) { Role.find_by(name: 'cfp', resource: conference) } diff --git a/spec/features/cfp_spec.rb b/spec/features/cfp_spec.rb index 7ecfb1e6..40971393 100644 --- a/spec/features/cfp_spec.rb +++ b/spec/features/cfp_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' feature Conference do - let!(:conference) { create(:conference) } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } @@ -17,20 +18,22 @@ feature Conference do click_button 'Create Cfp' expect(flash) - .to eq('Creating the call for papers failed. ' + + .to eq('Creating the call for papers failed. ' \ "Start date can't be blank. End date can't be blank.") today = Date.today - 1 page.execute_script( - "$('#registration-period-start-datepicker').val('#{today.strftime('%d/%m/%Y')}')") + "$('#registration-period-start-datepicker').val('#{today.strftime('%d/%m/%Y')}')" + ) page.execute_script( - "$('#registration-period-end-datepicker').val('#{(today + 6).strftime('%d/%m/%Y')}')") + "$('#registration-period-end-datepicker').val('#{(today + 6).strftime('%d/%m/%Y')}')" + ) click_button 'Create Cfp' # Validations expect(flash) - .to eq('Call for papers successfully created.') + .to eq('Call for papers successfully created.') visit admin_conference_program_cfp_path(conference.short_title, conference.program.cfp) expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y')) @@ -49,24 +52,27 @@ feature Conference do # Validate update with empty start date will not saved page.execute_script( - "$('#registration-period-start-datepicker').val('')") + "$('#registration-period-start-datepicker').val('')" + ) click_button 'Update Cfp' expect(flash) - .to eq('Updating call for papers failed. ' + + .to eq('Updating call for papers failed. ' \ "Start date can't be blank.") # Fill in date today = Date.today - 9 page.execute_script( - "$('#registration-period-start-datepicker').val('#{today.strftime('%d/%m/%Y')}')") + "$('#registration-period-start-datepicker').val('#{today.strftime('%d/%m/%Y')}')" + ) page.execute_script( - "$('#registration-period-end-datepicker').val('#{(today + 14).strftime('%d/%m/%Y')}')") + "$('#registration-period-end-datepicker').val('#{(today + 14).strftime('%d/%m/%Y')}')" + ) click_button 'Update Cfp' # Validations expect(flash) - .to eq('Call for papers successfully updated.') + .to eq('Call for papers successfully updated.') visit admin_conference_program_cfp_path(conference.short_title, conference.program.cfp) expect(find('#start_date').text).to eq(today.strftime('%A, %B %-d. %Y')) diff --git a/spec/features/commercials_spec.rb b/spec/features/commercials_spec.rb index d460a725..84bca335 100644 --- a/spec/features/commercials_spec.rb +++ b/spec/features/commercials_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Commercial do diff --git a/spec/features/conference_registration_spec.rb b/spec/features/conference_registration_spec.rb index 32ea2320..82f4a111 100644 --- a/spec/features/conference_registration_spec.rb +++ b/spec/features/conference_registration_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Registration do diff --git a/spec/features/conference_spec.rb b/spec/features/conference_spec.rb index bfd0be39..286b8a52 100644 --- a/spec/features/conference_spec.rb +++ b/spec/features/conference_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Conference do @@ -18,20 +20,20 @@ feature Conference do today = Time.zone.today - 1 page - .execute_script("$('#conference-start-datepicker').val('" + + .execute_script("$('#conference-start-datepicker').val('" \ "#{today.strftime('%d/%m/%Y')}')") page - .execute_script("$('#conference-end-datepicker').val('" + + .execute_script("$('#conference-end-datepicker').val('" \ "#{(today + 7).strftime('%d/%m/%Y')}')") click_button 'Create Conference' expect(flash) - .to eq('Conference was successfully created.') + .to eq('Conference was successfully created.') expect(Conference.count).to eq(expected_count) expect(Conference.last.organization).to eq(organization) user.reload - expect(user.has_cached_role? :organizer, Conference.last).to eq(true) + expect(user.has_cached_role?(:organizer, Conference.last)).to eq(true) end scenario 'update conference', feature: true, js: true do @@ -49,22 +51,22 @@ feature Conference do click_button 'Update Conference' expect(flash) - .to eq("Updating conference failed. Short title can't be blank.") + .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 = Time.zone.today + 10 page - .execute_script("$('#conference-start-datepicker').val('" + + .execute_script("$('#conference-start-datepicker').val('" \ "#{day.strftime('%d/%m/%Y')}')") page - .execute_script("$('#conference-end-datepicker').val('" + + .execute_script("$('#conference-end-datepicker').val('" \ "#{(day + 7).strftime('%d/%m/%Y')}')") click_button 'Update Conference' expect(flash) - .to eq('Conference was successfully updated.') + .to eq('Conference was successfully updated.') conference.reload expect(conference.title).to eq('New Con') diff --git a/spec/features/contact_spec.rb b/spec/features/contact_spec.rb index 513f3cab..9201644d 100644 --- a/spec/features/contact_spec.rb +++ b/spec/features/contact_spec.rb @@ -1,13 +1,13 @@ +# frozen_string_literal: true + require 'spec_helper' feature Contact do - let!(:conference) { create(:conference) } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) } shared_examples 'update a contact' do - scenario 'sucessfully', feature: true, js: true do contact = conference.contact expected_count = Contact.count @@ -26,7 +26,7 @@ feature Contact do click_button 'Update Contact' expect(flash) - .to eq('Contact details were successfully updated.') + .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') @@ -42,5 +42,4 @@ feature Contact do describe 'organizer' do it_behaves_like 'update a contact', :organizer end - end diff --git a/spec/features/difficulty_levels_spec.rb b/spec/features/difficulty_levels_spec.rb index 64427547..f6b881ba 100644 --- a/spec/features/difficulty_levels_spec.rb +++ b/spec/features/difficulty_levels_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature DifficultyLevel do @@ -7,10 +9,10 @@ feature DifficultyLevel do shared_examples 'difficulty levels' do scenario 'adds difficulty level', feature: true, js: true do - sign_in organizer visit admin_conference_program_difficulty_levels_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) # Add difficulty level click_link 'Add Difficulty Level' @@ -31,11 +33,11 @@ feature DifficultyLevel do end scenario 'updates difficulty level', feature: true, js: true do - conference.program.difficulty_levels << create(:difficulty_level) sign_in organizer visit admin_conference_program_difficulty_levels_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) # Remove difficulty level within('table tr:nth-of-type(4)') do @@ -51,7 +53,6 @@ feature DifficultyLevel do expect(page.has_content?('Hard Events')).to be true end end - end describe 'organizer' do diff --git a/spec/features/email_spec.rb b/spec/features/email_spec.rb index c1bfef5d..39aeff3e 100644 --- a/spec/features/email_spec.rb +++ b/spec/features/email_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature EmailSettings do @@ -54,7 +56,7 @@ feature EmailSettings do click_button 'Update Email settings' expect(flash) - .to eq('Email settings have been successfully updated.') + .to eq('Email settings have been successfully updated.') expect(find('#email_settings_registration_subject') .value).to eq('Registration subject') @@ -88,7 +90,6 @@ feature EmailSettings do .value).to eq('Updated conference venue template') expect(EmailSettings.count).to eq(expected_count) - end end diff --git a/spec/features/event_types_spec.rb b/spec/features/event_types_spec.rb index 6b3c9f0c..c6093c86 100644 --- a/spec/features/event_types_spec.rb +++ b/spec/features/event_types_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature EventType do @@ -7,10 +9,10 @@ feature EventType do shared_examples 'event types' do scenario 'adds and updates event type', feature: true do - sign_in organizer visit admin_conference_program_event_types_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) within('table#event_types') do expect(page.assert_selector('tr', count: 2)).to be true diff --git a/spec/features/info_desk_ability_spec.rb b/spec/features/info_desk_ability_spec.rb index f4ef4fce..e32d6cb8 100644 --- a/spec/features/info_desk_ability_spec.rb +++ b/spec/features/info_desk_ability_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' feature 'Has correct abilities' do - let(:organization) { create(:organization) } let(:conference) { create(:full_conference, organization: organization) } let(:role_info_desk) { Role.find_by(name: 'info_desk', resource: conference) } diff --git a/spec/features/lodgings_spec.rb b/spec/features/lodgings_spec.rb index 1e6b491d..5f265a54 100644 --- a/spec/features/lodgings_spec.rb +++ b/spec/features/lodgings_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Lodging do @@ -10,7 +12,8 @@ feature Lodging do sign_in organizer visit admin_conference_lodgings_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) # Add lodging click_link 'Add Lodging' @@ -33,7 +36,8 @@ feature Lodging do sign_in organizer visit admin_conference_lodgings_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) expect(page.has_content?(CGI.escapeHTML(lodging.name))).to be true @@ -61,7 +65,8 @@ feature Lodging do sign_in organizer visit admin_conference_lodgings_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) expect(page.has_content?(lodging.name)).to be true diff --git a/spec/features/omniauth_spec.rb b/spec/features/omniauth_spec.rb index 419d1f03..e346bba0 100644 --- a/spec/features/omniauth_spec.rb +++ b/spec/features/omniauth_spec.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true + require 'spec_helper' feature Openid do shared_examples 'sign in with openid' do - scenario 'has option to log in with Google account' do visit '/accounts/sign_in' expect(page.has_content?('or sign in using')).to be true diff --git a/spec/features/organization_admin_ability_spec.rb b/spec/features/organization_admin_ability_spec.rb index d84a7c01..6fa6b090 100644 --- a/spec/features/organization_admin_ability_spec.rb +++ b/spec/features/organization_admin_ability_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature 'Has correct abilities' do diff --git a/spec/features/organization_spec.rb b/spec/features/organization_spec.rb index 72948c2d..e2cf2fb0 100644 --- a/spec/features/organization_spec.rb +++ b/spec/features/organization_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Organization do diff --git a/spec/features/organizer_ability_spec.rb b/spec/features/organizer_ability_spec.rb index 0127ea2f..15e127ee 100644 --- a/spec/features/organizer_ability_spec.rb +++ b/spec/features/organizer_ability_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' feature 'Has correct abilities' do - let(:organization) { create(:organization) } let(:conference) { create(:full_conference, organization: organization) } let(:other_conference) { create(:conference, organization: organization) } # user is organizer, venue is not set by default diff --git a/spec/features/program_spec.rb b/spec/features/program_spec.rb index 369a0525..f4c13a93 100644 --- a/spec/features/program_spec.rb +++ b/spec/features/program_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' feature Program do - let!(:conference) { create(:conference) } let!(:program) { conference.program } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } @@ -23,7 +24,7 @@ feature Program do # Validations expect(flash) - .to eq('The program was successfully updated.') + .to eq('The program was successfully updated.') expect(find('#rating').text).to eq('4') end end diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index bef01e43..a5ad2430 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Event do diff --git a/spec/features/registration_periods_spec.rb b/spec/features/registration_periods_spec.rb index 5c1c90b5..4faff9b3 100644 --- a/spec/features/registration_periods_spec.rb +++ b/spec/features/registration_periods_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' feature RegistrationPeriod do - # It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } @@ -12,20 +13,21 @@ feature RegistrationPeriod do scenario 'create and update registration period', js: true do sign_in organizer visit admin_conference_registration_period_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) click_link 'New Registration Period' click_button 'Save Registration Period' expect(flash) - .to eq('An error prohibited the Registration Period from being saved: ' \ + .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('" + + .execute_script("$('#registration-period-start-datepicker').val('" \ "#{Date.today.strftime('%d/%m/%Y')}')") page - .execute_script("$('#registration-period-end-datepicker').val('" + + .execute_script("$('#registration-period-end-datepicker').val('" \ "#{(Date.today + 5).strftime('%d/%m/%Y')}')") click_button 'Save Registration Period' diff --git a/spec/features/resource_spec.rb b/spec/features/resource_spec.rb index 1d5c0437..895588aa 100644 --- a/spec/features/resource_spec.rb +++ b/spec/features/resource_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Resource do diff --git a/spec/features/roles_spec.rb b/spec/features/roles_spec.rb index 00d15006..9b01d493 100644 --- a/spec/features/roles_spec.rb +++ b/spec/features/roles_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Role do diff --git a/spec/features/rooms_spec.rb b/spec/features/rooms_spec.rb index d4ff4e0a..beb7402f 100644 --- a/spec/features/rooms_spec.rb +++ b/spec/features/rooms_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Room do @@ -10,7 +12,8 @@ feature Room do scenario 'adds a room', feature: true, js: true do sign_in organizer visit admin_conference_venue_rooms_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) expect(page.has_no_table?('#rooms')).to be true @@ -34,7 +37,8 @@ feature Room do room = create(:room, venue: venue) sign_in organizer visit edit_admin_conference_venue_room_path( - conference_id: conference.short_title, id: room.id) + conference_id: conference.short_title, id: room.id + ) fill_in 'room_name', with: 'Auditorium' fill_in 'room_size', with: '100' diff --git a/spec/features/splashpage_spec.rb b/spec/features/splashpage_spec.rb index 006df419..69c31052 100644 --- a/spec/features/splashpage_spec.rb +++ b/spec/features/splashpage_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' feature Splashpage do - # It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } @@ -20,7 +21,7 @@ feature Splashpage do end context 'splashpage already created' do - let!(:splashpage) { create(:splashpage, conference: conference, public: false)} + let!(:splashpage) { create(:splashpage, conference: conference, public: false) } scenario 'update a valid splashpage', js: true do sign_in organizer @@ -63,7 +64,7 @@ feature Splashpage do end context 'navigation' do - let!(:splashpage) { create(:splashpage, conference: conference, public: true)} + let!(:splashpage) { create(:splashpage, conference: conference, public: true) } context 'multiple organizations' do let!(:additional_organization) { create(:organization) } diff --git a/spec/features/sponsor_spec.rb b/spec/features/sponsor_spec.rb index b12ee90d..ef517406 100644 --- a/spec/features/sponsor_spec.rb +++ b/spec/features/sponsor_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Sponsor do @@ -13,7 +15,8 @@ feature Sponsor do sign_in organizer visit admin_conference_sponsors_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) # Add sponsors click_link 'Add Sponsor' diff --git a/spec/features/sponsorship_level_spec.rb b/spec/features/sponsorship_level_spec.rb index 3140a16b..5d30da88 100644 --- a/spec/features/sponsorship_level_spec.rb +++ b/spec/features/sponsorship_level_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature SponsorshipLevel do @@ -9,7 +11,8 @@ feature SponsorshipLevel do scenario 'adds a sponsorship level', feature: true, js: true do sign_in organizer visit admin_conference_sponsorship_levels_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) expect(page.has_no_table?('#sponsorship_levels')).to be true @@ -32,7 +35,8 @@ feature SponsorshipLevel do level = create(:sponsorship_level, conference_id: conference.id) sign_in organizer visit edit_admin_conference_sponsorship_level_path( - conference_id: conference.short_title, id: level.id) + conference_id: conference.short_title, id: level.id + ) fill_in 'sponsorship_level_title', with: 'Gold' diff --git a/spec/features/ticket_purchases_spec.rb b/spec/features/ticket_purchases_spec.rb index 9cace981..8b675557 100644 --- a/spec/features/ticket_purchases_spec.rb +++ b/spec/features/ticket_purchases_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Registration do @@ -18,7 +20,6 @@ feature Registration do end context 'who is not registered' do - scenario 'purchases and pays for a ticket succcessfully', feature: true, js: true do visit root_path click_link 'Register' @@ -143,7 +144,6 @@ feature Registration do end context 'who is registered' do - scenario 'unregisters from conference, but ticket purchases dont delete', feature: true, js: true do visit root_path click_link 'Register' diff --git a/spec/features/tickets_spec.rb b/spec/features/tickets_spec.rb index ab513cd1..3aae729f 100644 --- a/spec/features/tickets_spec.rb +++ b/spec/features/tickets_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Ticket do diff --git a/spec/features/track_organizer_ability_spec.rb b/spec/features/track_organizer_ability_spec.rb index 67e0c8de..876b254a 100644 --- a/spec/features/track_organizer_ability_spec.rb +++ b/spec/features/track_organizer_ability_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' feature 'Has correct abilities' do - let(:organization) { create(:organization) } let(:conference) { create(:full_conference, organization: organization) } let(:self_organized_track) { create(:track, :self_organized, program: conference.program, state: 'confirmed') } diff --git a/spec/features/tracks_spec.rb b/spec/features/tracks_spec.rb index f753abc2..3d4916bc 100644 --- a/spec/features/tracks_spec.rb +++ b/spec/features/tracks_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Track do @@ -8,7 +10,6 @@ feature Track do shared_examples 'admin tracks' do scenario 'adds a track', feature: true, js: true do - sign_in organizer expected = expect do @@ -78,7 +79,6 @@ feature Track do shared_examples 'non admin tracks' do scenario 'adds a track', feature: true, js: true do - sign_in user expected = expect do diff --git a/spec/features/user_ability_spec.rb b/spec/features/user_ability_spec.rb index d56e7441..aa33ef9e 100644 --- a/spec/features/user_ability_spec.rb +++ b/spec/features/user_ability_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' feature 'Has correct abilities' do - let(:organization) { create(:organization) } let(:conference) { create(:full_conference, organization: organization) } # user is cfp let(:user) { create(:user) } diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index 7294ec5c..385c17d9 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -1,9 +1,9 @@ +# frozen_string_literal: true + require 'spec_helper' feature User do - shared_examples 'admin ability' do - end describe 'admin' do diff --git a/spec/features/venues_spec.rb b/spec/features/venues_spec.rb index 2931b6e8..771815e7 100644 --- a/spec/features/venues_spec.rb +++ b/spec/features/venues_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Conference do @@ -7,12 +9,12 @@ feature Conference do shared_examples 'venue' do scenario 'adds and updates venue' do - sign_in organizer # create the venue visit admin_conference_venue_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) click_link 'Create Venue' fill_in 'venue_name', with: 'Example University' fill_in 'venue_street', with: 'Example Street 42' @@ -25,7 +27,7 @@ feature Conference do 'sadipscing elitr, sed diam nonumy eirmod tempor' click_button 'Create Venue' expect(flash) - .to eq('Venue was successfully created.') + .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') @@ -42,7 +44,7 @@ feature Conference do fill_in 'venue_description', with: 'new' click_button 'Update Venue' expect(flash) - .to eq('Venue was successfully updated.') + .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') @@ -53,5 +55,4 @@ feature Conference do describe 'organizer' do it_behaves_like 'venue' end - end diff --git a/spec/features/versions_spec.rb b/spec/features/versions_spec.rb index 3030d2b1..ac0ef163 100644 --- a/spec/features/versions_spec.rb +++ b/spec/features/versions_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature 'Version' do @@ -34,7 +36,7 @@ feature 'Version' do scenario 'display changes in cfp', feature: true, versioning: true, js: true do cfp = create(:cfp, program: conference.program) - cfp.update_attributes(start_date: (Time.zone.today + 1).strftime('%d/%m/%Y'), end_date: (Time.zone.today + 3).strftime('%d/%m/%Y')) + cfp.update(start_date: (Time.zone.today + 1).strftime('%d/%m/%Y'), end_date: (Time.zone.today + 3).strftime('%d/%m/%Y')) cfp_id = cfp.id cfp.destroy @@ -46,7 +48,7 @@ feature 'Version' do scenario 'display changes in registration_period', feature: true, versioning: true, js: true do registration_period = create(:registration_period, conference: conference) - registration_period.update_attributes(start_date: (Time.zone.today + 1).strftime('%d/%m/%Y'), end_date: (Time.zone.today + 3).strftime('%d/%m/%Y')) + registration_period.update(start_date: (Time.zone.today + 1).strftime('%d/%m/%Y'), end_date: (Time.zone.today + 3).strftime('%d/%m/%Y')) registration_period_id = registration_period.id registration_period.destroy @@ -59,7 +61,7 @@ feature 'Version' do scenario 'display changes in conference', feature: true, versioning: true, js: true do new_conference = create(:conference, title: 'Test Conference') organizer.add_role :organizer, new_conference - new_conference.update_attributes(title: 'New Con', short_title: 'NewCon') + new_conference.update(title: 'New Con', short_title: 'NewCon') visit admin_revision_history_path select '100', from: 'versionstable_length' @@ -71,7 +73,7 @@ feature 'Version' do scenario 'display changes in event_type', feature: true, versioning: true, js: true do event_type = create(:event_type, program: conference.program, name: 'Discussion') - event_type.update_attributes(length: 90, maximum_abstract_length: 10000) + event_type.update(length: 90, maximum_abstract_length: 10_000) event_type_id = event_type.id event_type.destroy @@ -83,7 +85,7 @@ feature 'Version' do scenario 'display changes in lodging', feature: true, versioning: true, js: true do lodging = create(:lodging, conference: conference, name: 'Hotel XYZ') - lodging.update_attributes(description: 'Nice view,close to venue', website_link: 'http://www.example.com') + lodging.update(description: 'Nice view,close to venue', website_link: 'http://www.example.com') lodging_id = lodging.id lodging.destroy @@ -105,7 +107,7 @@ feature 'Version' do scenario 'display changes in room', feature: true, versioning: true, js: true do venue = create(:venue, conference: conference) room = create(:room, venue: venue, name: 'Auditorium') - room.update_attributes(size: 120) + room.update(size: 120) room_id = room.id room.destroy @@ -118,7 +120,7 @@ feature 'Version' do scenario 'display changes in sponsor', feature: true, versioning: true, js: true do conference.sponsorship_levels << create_list(:sponsorship_level, 2, conference: conference) sponsor = create(:sponsor, conference: conference, name: 'SUSE', sponsorship_level: conference.sponsorship_levels.first) - sponsor.update_attributes(website_url: 'https://www.suse.com/company/history', sponsorship_level: conference.sponsorship_levels.second) + sponsor.update(website_url: 'https://www.suse.com/company/history', sponsorship_level: conference.sponsorship_levels.second) sponsor.destroy sponsor_id = sponsor.id @@ -130,7 +132,7 @@ feature 'Version' do scenario 'display changes in sponsorship_level', feature: true, versioning: true, js: true do sponsorship_level = create(:sponsorship_level, conference: conference) - sponsorship_level.update_attributes(title: 'Gold') + sponsorship_level.update(title: 'Gold') sponsorship_level_id = sponsorship_level.id sponsorship_level.destroy @@ -142,7 +144,7 @@ feature 'Version' do scenario 'display changes in ticket', feature: true, versioning: true, js: true do ticket = create(:ticket, conference: conference, title: 'Gold') - ticket.update_attributes(price: 50, description: 'Premium Ticket') + ticket.update(price: 50, description: 'Premium Ticket') ticket_id = ticket.id ticket.destroy @@ -154,7 +156,7 @@ feature 'Version' do scenario 'display changes in track', feature: true, versioning: true, js: true do track = create(:track, program: conference.program, name: 'Distribution') - track.update_attributes(description: 'Events about Linux distributions') + track.update(description: 'Events about Linux distributions') track_id = track.id track.destroy @@ -166,7 +168,7 @@ feature 'Version' do scenario 'display changes in venue', feature: true, versioning: true, js: true do venue = create(:venue, conference: conference, name: 'Example University') - venue.update_attributes(website: 'www.example.com new', description: 'Just another beautiful venue') + venue.update(website: 'www.example.com new', description: 'Just another beautiful venue') venue_id = venue.id venue.destroy @@ -220,7 +222,7 @@ feature 'Version' do scenario 'display changes in difficulty levels', feature: true, versioning: true, js: true do difficulty_level = create(:difficulty_level, program: conference.program, title: 'Expert') - difficulty_level.update_attributes(description: 'Only for Experts') + difficulty_level.update(description: 'Only for Experts') difficulty_level_id = difficulty_level.id difficulty_level.destroy @@ -271,7 +273,7 @@ feature 'Version' do scenario 'display changes in conference commercials', feature: true, versioning: true, js: true do conference_commercial = create(:conference_commercial, commercialable: conference) - conference_commercial.update_attributes(url: 'https://www.youtube.com/watch?v=VNkDJk5_9eU') + conference_commercial.update(url: 'https://www.youtube.com/watch?v=VNkDJk5_9eU') conference_commercial.destroy visit admin_revision_history_path @@ -282,7 +284,7 @@ feature 'Version' do scenario 'display changes in event commercials', feature: true, versioning: true, js: true do event_commercial - event_commercial.update_attributes(url: 'https://www.youtube.com/watch?v=VNkDJk5_9eU') + event_commercial.update(url: 'https://www.youtube.com/watch?v=VNkDJk5_9eU') event_commercial.destroy visit admin_revision_history_path @@ -340,7 +342,7 @@ feature 'Version' do end scenario 'display changes in email settings', feature: true, versioning: true, js: true do - conference.email_settings.update_attributes(registration_subject: 'xxxxx', registration_body: 'yyyyy', accepted_subject: 'zzzzz') + conference.email_settings.update(registration_subject: 'xxxxx', registration_body: 'yyyyy', accepted_subject: 'zzzzz') visit admin_revision_history_path expect(page).to have_text("Someone (probably via the console) updated registration body, registration subject and accepted subject @@ -361,7 +363,7 @@ feature 'Version' do registration = Registration.create(user: organizer, conference: conference) event = create(:event, program: conference.program, title: 'My second event') EventsRegistration.create(registration: registration, event: event) - EventsRegistration.first.update_attributes(attended: true) + EventsRegistration.first.update(attended: true) EventsRegistration.last.destroy # Here registration is deleted to ensure the event registration related change still displays the asociated user's name registration.destroy @@ -374,7 +376,7 @@ feature 'Version' do scenario 'display changes in target', feature: true, versioning: true, js: true do target = create(:target, conference: conference) - target.update_attributes(due_date: Date.today, target_count: 1000) + target.update(due_date: Date.today, target_count: 1000) target_id = target.id target.destroy @@ -416,7 +418,7 @@ feature 'Version' do scenario 'display changes in campaign', feature: true, versioning: true, js: true do campaign = create(:campaign, conference: conference, name: 'Test Campaign', utm_campaign: 'campaign') - campaign.update_attributes(utm_source: 'source', utm_medium: 'medium', utm_term: 'term', utm_content: 'content') + campaign.update(utm_source: 'source', utm_medium: 'medium', utm_term: 'term', utm_content: 'content') campaign_id = campaign.id campaign.destroy @@ -443,7 +445,7 @@ feature 'Version' do scenario 'display updates to user', feature: true, versioning: true, js: true do user = create(:user) - user.update_attributes(nickname: 'testnick', affiliation: 'openSUSE') + user.update(nickname: 'testnick', affiliation: 'openSUSE') visit admin_revision_history_path expect(page).to have_text("Someone (probably via the console) updated nickname and affiliation of user #{user.name}") diff --git a/spec/features/volunteers_spec.rb b/spec/features/volunteers_spec.rb index a27ba0b1..6f267900 100644 --- a/spec/features/volunteers_spec.rb +++ b/spec/features/volunteers_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' feature Conference do @@ -9,41 +11,42 @@ feature Conference do scenario 'adds and updates vdays', feature: true, js: true do sign_in(organizer) visit admin_conference_volunteers_info_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) check('Enable Volunteering') check('Use vdays') -# click_link 'Add vday' -# expect(page.all('div.nested-fields').count == 1).to be true -# page. -# find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)'). -# select("#{Date.today.strftime('%Y')}") -# page. -# find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)'). -# select("#{Date.today.strftime('%B')}") -# page. -# find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)'). -# select("#{Date.today.strftime('%-d')}") -# page. -# find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea'). -# set('Example Person') + # click_link 'Add vday' + # expect(page.all('div.nested-fields').count == 1).to be true + # page. + # find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)'). + # select("#{Date.today.strftime('%Y')}") + # page. + # find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)'). + # select("#{Date.today.strftime('%B')}") + # page. + # find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)'). + # select("#{Date.today.strftime('%-d')}") + # page. + # 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.') + .to eq('Volunteering options were successfully updated.') -# # Validations -# expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)'). -# value).to eq("#{Date.today.strftime('%Y')}") -# expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)'). -# value).to eq("#{Date.today.month}") -# expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)'). -# value).to eq("#{Date.today.strftime('%-d')}") -# expect( -# find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea'). -# value).to eq('Example Person') -# -# # Remove vday -# click_link 'Remove vday' -# expect(page.all('div.nested-fields').count == 0).to be true + # # Validations + # expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)'). + # value).to eq("#{Date.today.strftime('%Y')}") + # expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)'). + # value).to eq("#{Date.today.month}") + # expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)'). + # value).to eq("#{Date.today.strftime('%-d')}") + # expect( + # find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea'). + # value).to eq('Example Person') + # + # # Remove vday + # click_link 'Remove vday' + # expect(page.all('div.nested-fields').count == 0).to be true click_button 'Update Conference' expect(flash).to eq('Volunteering options were successfully updated.') expect(page.all('div.nested-fields').count == 0).to be true @@ -53,65 +56,66 @@ feature Conference do scenario 'adds and updates vpositions', feature: true, js: true do sign_in(organizer) visit admin_conference_volunteers_info_path( - conference_id: conference.short_title) + conference_id: conference.short_title + ) # Adding vday check('Enable Volunteering') check('Use vdays') -# click_link 'Add vday' -# expect(page.all('div.nested-fields').count == 1).to be true -# page. -# find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)'). -# select("#{Date.today.strftime('%Y')}") -# page. -# find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)'). -# select("#{Date.today.strftime('%B')}") -# page. -# find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)'). -# select("#{Date.today.strftime('%-d')}") -# page. -# find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea'). -# set('Example Person') + # click_link 'Add vday' + # expect(page.all('div.nested-fields').count == 1).to be true + # page. + # find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)'). + # select("#{Date.today.strftime('%Y')}") + # page. + # find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)'). + # select("#{Date.today.strftime('%B')}") + # page. + # find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)'). + # select("#{Date.today.strftime('%-d')}") + # page. + # 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.') + .to eq('Volunteering options were successfully updated.') # Add vposition check('Use vpositions') -# click_link 'Add vposition' -# expect(page.all('div.nested-fields').count == 2).to be true -# page.find('div.vpositions div.nested-fields:nth-of-type(1)'\ -# ' div:nth-of-type(1) input'). -# set('Example Position') -# page.find('div.vpositions div.nested-fields:nth-of-type(1)'\ -# ' div:nth-of-type(2) textarea'). -# set('Example Description') -# find(:css, "select[id^='conference_vpositions_attributes_']"\ -# "[id$='_vday_ids']"). -# find(:option, "#{Date.today.strftime}").select_option + # click_link 'Add vposition' + # expect(page.all('div.nested-fields').count == 2).to be true + # page.find('div.vpositions div.nested-fields:nth-of-type(1)'\ + # ' div:nth-of-type(1) input'). + # set('Example Position') + # page.find('div.vpositions div.nested-fields:nth-of-type(1)'\ + # ' div:nth-of-type(2) textarea'). + # set('Example Description') + # find(:css, "select[id^='conference_vpositions_attributes_']"\ + # "[id$='_vday_ids']"). + # find(:option, "#{Date.today.strftime}").select_option click_button 'Update Conference' expect(flash) - .to eq('Volunteering options were successfully updated.') + .to eq('Volunteering options were successfully updated.') # Validations -# expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\ -# ' div:nth-of-type(1) input'). -# value).to eq('Example Position') -# expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\ -# ' div:nth-of-type(2) textarea'). -# value).to eq('Example Description') -# -# expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\ -# ' div:nth-of-type(3) select:nth-of-type(1)').find('option[selected]'). -# text).to eq(Date.today.strftime) + # expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\ + # ' div:nth-of-type(1) input'). + # value).to eq('Example Position') + # expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\ + # ' div:nth-of-type(2) textarea'). + # value).to eq('Example Description') + # + # expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\ + # ' div:nth-of-type(3) select:nth-of-type(1)').find('option[selected]'). + # text).to eq(Date.today.strftime) # Remove vposition -# click_link 'Remove vposition' -# expect(page.all('div.nested-fields').count == 1).to be true -# click_button 'Update Conference' + # click_link 'Remove vposition' + # expect(page.all('div.nested-fields').count == 1).to be true + # click_button 'Update Conference' expect(flash).to eq('Volunteering options were successfully updated.') -# click_link 'Remove vday' -# expect(page.all('div.nested-fields').count == 0).to be true + # click_link 'Remove vday' + # expect(page.all('div.nested-fields').count == 0).to be true sign_out end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index ff0fbfa2..4222c079 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ApplicationHelper, type: :helper do @@ -27,7 +29,7 @@ describe ApplicationHelper, type: :helper do before :each do @other_event = create(:event, program: conference.program, state: 'confirmed') schedule = create(:schedule, program: conference.program) - conference.program.update_attributes!(selected_schedule: schedule) + conference.program.update!(selected_schedule: schedule) @event_schedule = create(:event_schedule, event: event, start_time: conference.start_date + conference.start_hour.hours, room: create(:room), schedule: schedule) @other_event_schedule = create(:event_schedule, event: @other_event, start_time: conference.start_date + conference.start_hour.hours, room: create(:room), schedule: schedule) end @@ -38,7 +40,7 @@ describe ApplicationHelper, type: :helper do end it 'when event is in between the other event' do - @event_schedule.update_attributes!(start_time: @other_event_schedule.start_time + 10.minutes) + @event_schedule.update!(start_time: @other_event_schedule.start_time + 10.minutes) expect(concurrent_events(event).include?(@other_event)).to eq true end end @@ -50,12 +52,12 @@ describe ApplicationHelper, type: :helper do end it 'when one event starts and other ends at the same time' do - @event_schedule.update_attributes!(start_time: @other_event_schedule.end_time) + @event_schedule.update!(start_time: @other_event_schedule.end_time) expect(concurrent_events(event).present?).to eq false end it 'when conference program does not have a selected schedule' do - conference.program.update_attributes!(selected_schedule_id: nil) + conference.program.update!(selected_schedule_id: nil) expect(concurrent_events(event).present?).to eq false end end @@ -81,7 +83,7 @@ describe ApplicationHelper, type: :helper do context 'first sponsorship_level' do before do first_sponsorship_level = create(:sponsorship_level, position: 1) - sponsor.update_attributes(sponsorship_level: first_sponsorship_level) + sponsor.update(sponsorship_level: first_sponsorship_level) end it 'returns correct url' do @@ -92,7 +94,7 @@ describe ApplicationHelper, type: :helper do context 'second sponsorship_level' do before do second_sponsorship_level = create(:sponsorship_level, position: 2) - sponsor.update_attributes(sponsorship_level: second_sponsorship_level) + sponsor.update(sponsorship_level: second_sponsorship_level) end it 'returns correct url' do @@ -103,7 +105,7 @@ describe ApplicationHelper, type: :helper do context 'other sponsorship_level' do before do other_sponsorship_level = create(:sponsorship_level, position: 3) - sponsor.update_attributes(sponsorship_level: other_sponsorship_level) + sponsor.update(sponsorship_level: other_sponsorship_level) end it 'returns correct url' do diff --git a/spec/helpers/conference_helper_spec.rb b/spec/helpers/conference_helper_spec.rb index 09e38e69..101d083a 100644 --- a/spec/helpers/conference_helper_spec.rb +++ b/spec/helpers/conference_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ConferenceHelper, type: :helper do diff --git a/spec/helpers/date_time_helper_spec.rb b/spec/helpers/date_time_helper_spec.rb index 09c7e4a4..97029c4c 100644 --- a/spec/helpers/date_time_helper_spec.rb +++ b/spec/helpers/date_time_helper_spec.rb @@ -1,14 +1,15 @@ +# frozen_string_literal: true + require 'spec_helper' describe DateTimeHelper, type: :helper do - describe 'format_datetime' do it 'returns nothing if there is no parameter' do expect(format_datetime(nil)).to eq nil end it 'returns formatted string' do - datetime = Time.zone.local(2016, 05, 04, 11, 30) + datetime = Time.zone.local(2016, 0o5, 0o4, 11, 30) expect(format_datetime(datetime)).to eq '2016-05-04 11:30' end end diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index baefebbc..a77c336b 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe EventsHelper, type: :helper do diff --git a/spec/helpers/format_helper_spec.rb b/spec/helpers/format_helper_spec.rb index f14de8b3..a997cafe 100644 --- a/spec/helpers/format_helper_spec.rb +++ b/spec/helpers/format_helper_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' describe FormatHelper, type: :helper do - describe 'markdown' do it 'should return empty string for nil' do expect(markdown(nil)).to eq '' @@ -9,8 +10,8 @@ describe FormatHelper, type: :helper do 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 + .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 "