Merge pull request #349 from openSUSE/review_140721_basic_rubocop_rules

[Review] Request from 'KalabiYau' @ 'openSUSE/osem/review_140721_basic_rubocop_rules'
This commit is contained in:
Artem Chernikov 2014-07-23 11:00:30 +02:00
commit d9d72eae07
103 changed files with 686 additions and 260 deletions

1
.gitignore vendored
View file

@ -28,4 +28,3 @@ pickle-email-*.html
/bundle /bundle
/doc/app /doc/app
.ruby-version .ruby-version
rubocop.yml

89
.rubocop.yml Normal file
View file

@ -0,0 +1,89 @@
inherit_from: .rubocop_todo.yml
Style/HashSyntax:
Enabled: true
EnforcedStyle: ruby19
# Things deprecated in current ruby API
Lint/DeprecatedClassMethods:
Enabled: true
# Do not compare with nil. Use .nil? instead
Style/NilComparison:
Enabled: true
# Use one empty line between method definitions
Style/EmptyLineBetweenDefs:
Enabled: true
# There should be only one empty line in designated place
Style/EmptyLines:
Enabled: true
# Keep a blank line before and after private.
Style/EmptyLinesAroundAccessModifier:
Enabled: true
# Do not insert empty line after class definition and before closing class
Style/EmptyLinesAroundBody:
Enabled: true
# Use hash literal {} instead of Hash.new
Style/EmptyLiteral:
Enabled: true
# Prefer `each` over `for i`
Style/For:
Enabled: true
# Wrap your assignment in condition if you mean it, otherwise it is most likely equality check
Lint/AssignmentInCondition:
Enabled: true
# Align blocks of code properly
Lint/BlockAlignment:
Enabled: true
# Do not use literal in conditions. We have it enabled for now
Lint/LiteralInCondition:
Enabled: false
# Prefer `Kernel#loop -> break` over `begin -> while`
Lint/Loop:
Enabled: true
# do not put space before arguments when they are in parentheses
Lint/ParenthesesAsGroupedExpression:
Enabled: true
# Do not rescue Exceptions class itself
Lint/RescueException:
Enabled: true
# do not shadow local variables in blocks, choose other name
Lint/ShadowingOuterLocalVariable:
Enabled: true
# use _ or variable_name to explicitly mark variable as unused
Lint/UnusedBlockArgument:
Enabled: true
# use _ or _argument_name to explicitly mark argument as unused
Lint/UnusedMethodArgument:
Enabled: true
# avoid useless assignment
Lint/UselessAssignment:
Enabled: true
# Do not use variables in void context
Lint/Void:
Enabled: true
AllCops:
Include:
- '**/Rakefile'
- '**/config.ru'
Exclude:
- 'db/schema.rb'
- 'vendor/bundle/**/*'

329
.rubocop_todo.yml Normal file
View file

@ -0,0 +1,329 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2014-07-21 12:48:09 +0200 using RuboCop version 0.24.1.
# 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: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
Style/AlignHash:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/AlignParameters:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
Style/AndOr:
Enabled: false
# Offense count: 1
Style/BlockNesting:
Max: 4
# Offense count: 2
# Cop supports --auto-correct.
Style/Blocks:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/BracesAroundHashParameters:
Enabled: false
# Offense count: 1
Style/CaseEquality:
Enabled: false
# Offense count: 20
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassCheck:
Enabled: false
# Offense count: 8
# Configuration parameters: CountComments.
Style/ClassLength:
Max: 524
# Offense count: 1
Style/ClassVars:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: PreferredMethods.
Style/CollectionMethods:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Style/ColonMethodCall:
Enabled: false
# Offense count: 4
# Configuration parameters: Keywords.
Style/CommentAnnotation:
Enabled: false
# Offense count: 4
# Cop supports --auto-correct.
Style/CommentIndentation:
Enabled: false
# Offense count: 10
Style/CyclomaticComplexity:
Max: 16
# Offense count: 5
# Cop supports --auto-correct.
Style/DeprecatedHashMethods:
Enabled: false
# Offense count: 228
Style/Documentation:
Enabled: false
# Offense count: 150
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/DotPosition:
Enabled: false
# Offense count: 9
Style/DoubleNegation:
Enabled: false
# Offense count: 1
# Configuration parameters: Exclude.
Style/FileName:
Enabled: false
# Offense count: 8
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false
# Offense count: 27
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
Style/IndentArray:
Enabled: false
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/IndentHash:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
Style/IndentationConsistency:
Enabled: false
# Offense count: 5
# Cop supports --auto-correct.
Style/IndentationWidth:
Enabled: false
# Offense count: 7
# Cop supports --auto-correct.
Style/LeadingCommentSpace:
Enabled: false
# Offense count: 5
# Cop supports --auto-correct.
Style/LineEndConcatenation:
Enabled: false
# Offense count: 515
# Configuration parameters: AllowURI.
Style/LineLength:
Max: 217
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MethodDefParentheses:
Enabled: false
# Offense count: 68
# Configuration parameters: CountComments.
Style/MethodLength:
Max: 134
# Offense count: 14
# Cop supports --auto-correct.
Style/NegatedIf:
Enabled: false
# Offense count: 18
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/Next:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Style/NumericLiterals:
MinDigits: 15
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowSafeAssignment.
Style/ParenthesesAroundCondition:
Enabled: false
# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Enabled: false
# Offense count: 2
# Configuration parameters: NamePrefixBlacklist.
Style/PredicateName:
Enabled: false
# Offense count: 3
# Configuration parameters: SupportedStyles.
Style/RaiseArgs:
EnforcedStyle: compact
# Offense count: 3
# Cop supports --auto-correct.
Style/RedundantBegin:
Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Enabled: false
# Offense count: 8
# Cop supports --auto-correct.
Style/RedundantSelf:
Enabled: false
# Offense count: 10
# Configuration parameters: MaxSlashes.
Style/RegexpLiteral:
Enabled: false
# Offense count: 1
Style/SelfAssignment:
Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SignalException:
Enabled: false
# Offense count: 1
# Configuration parameters: Methods.
Style/SingleLineBlockParams:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowIfMethodIsEmpty.
Style/SingleLineMethods:
Enabled: false
# Offense count: 285
# Cop supports --auto-correct.
Style/SingleSpaceBeforeFirstArg:
Enabled: false
# Offense count: 4
# Cop supports --auto-correct.
Style/SpaceAfterComma:
Enabled: false
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SpaceAroundEqualsInParameterDefault:
Enabled: false
# Offense count: 5
# Cop supports --auto-correct.
Style/SpaceAroundOperators:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SpaceBeforeBlockBraces:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Style/SpaceBeforeSemicolon:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
Style/SpaceInsideBlockBraces:
Enabled: false
# Offense count: 4
# Cop supports --auto-correct.
Style/SpaceInsideBrackets:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
Style/SpaceInsideHashLiteralBraces:
Enabled: false
# Offense count: 577
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/StringLiterals:
Enabled: false
# Offense count: 1
Style/Tab:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/TrailingBlankLines:
Enabled: false
# Offense count: 24
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
Style/TrailingComma:
Enabled: false
# Offense count: 38
# Cop supports --auto-correct.
Style/TrailingWhitespace:
Enabled: false
# Offense count: 8
# Cop supports --auto-correct.
Style/WordArray:
MinSize: 5
Style/AccessorMethodName:
Enabled: false

View file

@ -3,6 +3,7 @@ rvm:
- 2.1.1 - 2.1.1
before_install: before_install:
- "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
- "echo `phantomjs -v`"
branches: branches:
only: only:
- master - master
@ -16,4 +17,5 @@ before_script:
- cp config/secrets.yml.example config/secrets.yml - cp config/secrets.yml.example config/secrets.yml
- RAILS_ENV=test bundle exec rake db:migrate --trace - RAILS_ENV=test bundle exec rake db:migrate --trace
script: script:
- bundle exec rspec --color --format documentation - 'bundle exec rspec --color --format documentation'
- 'bundle exec rubocop -Dc .rubocop.yml'

View file

@ -128,3 +128,7 @@ group :test do
# Extracted from RSpec 3 stub_model and mock_model # Extracted from RSpec 3 stub_model and mock_model
gem 'rspec-activemodel-mocks' gem 'rspec-activemodel-mocks'
end end
group :development, :test do
gem 'debugger'
end

View file

@ -90,6 +90,7 @@ GEM
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.7.0) coffee-script-source (1.7.0)
columnize (0.8.9)
coveralls (0.7.0) coveralls (0.7.0)
multi_json (~> 1.3) multi_json (~> 1.3)
rest-client rest-client
@ -99,6 +100,12 @@ GEM
d3_rails (3.4.6) d3_rails (3.4.6)
railties (>= 3.1.0) railties (>= 3.1.0)
database_cleaner (1.3.0) database_cleaner (1.3.0)
debugger (1.6.8)
columnize (>= 0.3.1)
debugger-linecache (~> 1.2.0)
debugger-ruby_core_source (~> 1.3.5)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.3.5)
devise (3.2.4) devise (3.2.4)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
@ -221,7 +228,7 @@ GEM
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
cocaine (~> 0.5.3) cocaine (~> 0.5.3)
mime-types mime-types
parser (2.1.9) parser (2.2.0.pre.3)
ast (>= 1.1, < 3.0) ast (>= 1.1, < 3.0)
slop (~> 3.4, >= 3.4.5) slop (~> 3.4, >= 3.4.5)
pdf-core (0.2.5) pdf-core (0.2.5)
@ -310,9 +317,9 @@ GEM
rspec-mocks (~> 3.0.0) rspec-mocks (~> 3.0.0)
rspec-support (~> 3.0.0) rspec-support (~> 3.0.0)
rspec-support (3.0.2) rspec-support (3.0.2)
rubocop (0.22.0) rubocop (0.24.1)
json (>= 1.7.7, < 2) json (>= 1.7.7, < 2)
parser (~> 2.1.9) parser (>= 2.2.0.pre.3, < 3.0)
powerpack (~> 0.0.6) powerpack (~> 0.0.6)
rainbow (>= 1.99.1, < 3.0) rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4) ruby-progressbar (~> 1.4)
@ -336,7 +343,7 @@ GEM
multi_json multi_json
simplecov-html (~> 0.8.0) simplecov-html (~> 0.8.0)
simplecov-html (0.8.0) simplecov-html (0.8.0)
slop (3.5.0) slop (3.6.0)
spring (1.1.2) spring (1.1.2)
spring-commands-rspec (1.0.2) spring-commands-rspec (1.0.2)
spring (>= 0.9.1) spring (>= 0.9.1)
@ -399,6 +406,7 @@ DEPENDENCIES
coveralls coveralls
d3_rails d3_rails
database_cleaner database_cleaner
debugger
devise devise
factory_girl_rails factory_girl_rails
font-awesome-rails font-awesome-rails

View file

@ -87,6 +87,13 @@ bundle exec guard
This uses [spring](https://github.com/rails/spring) to provide a This uses [spring](https://github.com/rails/spring) to provide a
[fast feedback loop for the red/green cycle](http://bitzesty.com/blog/2013/05/enable-tdd-with-faster-ruby-on-rails-stack-reloading/). [fast feedback loop for the red/green cycle](http://bitzesty.com/blog/2013/05/enable-tdd-with-faster-ruby-on-rails-stack-reloading/).
## Style
We are using [rubocop](https://github.com/bbatsov/rubocop) as a style checker. It is running each time
Travis run its testing routine. If you want to run it locally just `bundle exec rubocop`.
You can read through current enabled rules in `.rubocop.yml` file. Explanations of the defined [rules](http://rubydoc.info/github/bbatsov/rubocop/master/frames) can be found in modules [Cop::Lint](http://rubydoc.info/github/bbatsov/rubocop/master/Rubocop/Cop/Lint) and [Cop::Style](http://rubydoc.info/github/bbatsov/rubocop/master/Rubocop/Cop/Style).
Additionally you can read through [community ruby style-guide](https://github.com/bbatsov/ruby-style-guide) to better understand core principles.
# Communication # Communication
GitHub issues are the primary way for communicating about specific proposed GitHub issues are the primary way for communicating about specific proposed
changes to this project. If you have other questions feel free to subscribe to changes to this project. If you have other questions feel free to subscribe to

View file

@ -8,9 +8,9 @@ class Admin::DietchoicesController < ApplicationController
def update def update
begin begin
@conference.update_attributes!(params[:conference]) @conference.update_attributes!(params[:conference])
redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :notice => 'Dietary choices were successfully updated.') redirect_to(admin_conference_dietary_list_path(conference_id: @conference.short_title), notice: 'Dietary choices were successfully updated.')
rescue Exception => e rescue => e
redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :alert => "Dietary choices update failed: #{e.message}") redirect_to(admin_conference_dietary_list_path(conference_id: @conference.short_title), alert: "Dietary choices update failed: #{e.message}")
end end
end end
end end

View file

@ -12,19 +12,18 @@ class Admin::DifficultyLevelsController < ApplicationController
@conference.use_difficulty_levels = false @conference.use_difficulty_levels = false
@conference.save! @conference.save!
flash[:error] = "You cannot enable the usage of difficulty levels without having set any levels." flash[:error] = "You cannot enable the usage of difficulty levels without having set any levels."
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title)) redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
rescue ActiveRecord::RecordInvalid rescue ActiveRecord::RecordInvalid
flash[:error] = "Something went wrong. Difficulty Levels update failed." flash[:error] = "Something went wrong. Difficulty Levels update failed."
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title)) redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
end end
else else
flash[:notice] = "Difficulty Levels were successfully updated." flash[:notice] = "Difficulty Levels were successfully updated."
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title)) redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
end end
else else
flash[:error] = "Difficulty Levels update failed." flash[:error] = "Difficulty Levels update failed."
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title)) redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
end end
end end
end end

View file

@ -18,7 +18,7 @@ module Admin
@mystates = [] @mystates = []
@mytypes = [] @mytypes = []
@eventstats = Hash.new @eventstats = {}
@totallength = 0 @totallength = 0
@machine_states.each do |mystate| @machine_states.each do |mystate|
@ -50,7 +50,7 @@ module Admin
@totallength += myevent.event_type.length @totallength += myevent.event_type.length
end end
if @eventstats[mytype.title] == nil if @eventstats[mytype.title].nil?
@eventstats[mytype.title] = { 'count' => events_mytype.count, @eventstats[mytype.title] = { 'count' => events_mytype.count,
'length' => events_mytype.count * mytype.length } 'length' => events_mytype.count * mytype.length }
end end
@ -150,7 +150,7 @@ module Admin
@event = Event.find(params[:id]) @event = Event.find(params[:id])
@ratings = @event.votes.includes(:user) @ratings = @event.votes.includes(:user)
if votes = current_user.votes.find_by_event_id(params[:id]) if (votes = current_user.votes.find_by_event_id(params[:id]))
votes.update_attributes(rating: params[:rating]) votes.update_attributes(rating: params[:rating])
else else
@myvote = @event.votes.build @myvote = @event.votes.build

View file

@ -10,7 +10,7 @@ class Admin::EventtypesController < ApplicationController
redirect_to(admin_conference_eventtypes_path( redirect_to(admin_conference_eventtypes_path(
conference_id: @conference.short_title), conference_id: @conference.short_title),
notice: 'Event types were successfully updated.') notice: 'Event types were successfully updated.')
rescue Exception => e rescue => e
redirect_to(admin_conference_eventtypes_path( redirect_to(admin_conference_eventtypes_path(
conference_id: @conference.short_title), conference_id: @conference.short_title),
alert: "Event types update failed: #{e.message}") alert: "Event types update failed: #{e.message}")

View file

@ -3,7 +3,7 @@ class Admin::QuestionsController < ApplicationController
def index def index
@conference = Conference.find_by(short_title: params[:conference_id]) @conference = Conference.find_by(short_title: params[:conference_id])
@questions = Question.where(:global => true).all | Question.where(:conference_id => @conference.id) @questions = Question.where(global: true).all | Question.where(conference_id: @conference.id)
@questions_conference = @conference.questions @questions_conference = @conference.questions
@new_question = @conference.questions.new @new_question = @conference.questions.new
end end
@ -34,7 +34,7 @@ class Admin::QuestionsController < ApplicationController
@question = Question.find(params[:id]) @question = Question.find(params[:id])
if @question.global == true && !has_role?(current_user, "Admin") if @question.global == true && !has_role?(current_user, "Admin")
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :alert => "Sorry, you cannot edit global questions. Create a new one.") redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), alert: "Sorry, you cannot edit global questions. Create a new one.")
end end
end end
@ -45,9 +45,9 @@ class Admin::QuestionsController < ApplicationController
@question = Question.find(params[:id]) @question = Question.find(params[:id])
if @question.update_attributes(params[:question]) if @question.update_attributes(params[:question])
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Question '#{@question.title}' for #{@conference.short_title} successfully updated.") redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Question '#{@question.title}' for #{@conference.short_title} successfully updated.")
else else
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Update of questions for #{@conference.short_title} failed.") redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed.")
end end
end end
@ -56,9 +56,9 @@ class Admin::QuestionsController < ApplicationController
@conference = Conference.find_by(short_title: params[:conference_id]) @conference = Conference.find_by(short_title: params[:conference_id])
if @conference.update_attributes(params[:conference]) if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Questions for #{@conference.short_title} successfully updated.") redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Questions for #{@conference.short_title} successfully updated.")
else else
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Update of questions for #{@conference.short_title} failed.") redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed.")
end end
end end
@ -79,7 +79,7 @@ class Admin::QuestionsController < ApplicationController
a.delete a.delete
end end
flash[:notice] = "Deleted question: #{@question.title} and its answers: #{@question.answers.map {|a| a.title}.join ','}" flash[:notice] = "Deleted question: #{@question.title} and its answers: #{@question.answers.map {|a| a.title}.join ','}"
end end
rescue ActiveRecord::RecordInvalid rescue ActiveRecord::RecordInvalid
flash[:error] = "Could not delete question." flash[:error] = "Could not delete question."
end end
@ -90,7 +90,7 @@ class Admin::QuestionsController < ApplicationController
flash[:error] = "You must be an admin to delete a question." flash[:error] = "You must be an admin to delete a question."
end end
@questions = Question.where(:global => true).all | Question.where(:conference_id => @conference.id) @questions = Question.where(global: true).all | Question.where(conference_id: @conference.id)
@questions_conference = @conference.questions @questions_conference = @conference.questions
end end
end end

View file

@ -44,7 +44,7 @@ module Admin
@registration.update_attributes!(params[:registration]) @registration.update_attributes!(params[:registration])
flash[:success] = "Successfully updated registration for #{@user.name} #{@user.email}" flash[:success] = "Successfully updated registration for #{@user.name} #{@user.email}"
redirect_to(admin_conference_registrations_path(@conference.short_title)) redirect_to(admin_conference_registrations_path(@conference.short_title))
rescue Exception => e rescue => e
Rails.logger.debug e.backtrace.join("\n") Rails.logger.debug e.backtrace.join("\n")
redirect_to(admin_conference_registrations_path(@conference.short_title), redirect_to(admin_conference_registrations_path(@conference.short_title),
alert: 'Failed to update registration:' + e.message) alert: 'Failed to update registration:' + e.message)
@ -104,7 +104,7 @@ module Admin
begin registration.destroy begin registration.destroy
redirect_to admin_conference_registrations_path redirect_to admin_conference_registrations_path
flash[:notice] = "Deleted registration for #{user.name} #{user.email}" flash[:notice] = "Deleted registration for #{user.name} #{user.email}"
rescue Exception => e rescue => e
Rails.logger.debug e.backtrace.join("\n") Rails.logger.debug e.backtrace.join("\n")
redirect_to(admin_conference_registrations_path(@conference.short_title), redirect_to(admin_conference_registrations_path(@conference.short_title),
alert: 'Failed to delete registration:' + e.message) alert: 'Failed to delete registration:' + e.message)

View file

@ -7,11 +7,9 @@ class Admin::SocialEventsController < ApplicationController
def update def update
if @conference.update_attributes(params[:conference]) if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events were successfully updated.') redirect_to(admin_conference_social_events_path(conference_id: @conference.short_title), notice: 'Social events were successfully updated.')
else else
redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events update failed.') redirect_to(admin_conference_social_events_path(conference_id: @conference.short_title), notice: 'Social events update failed.')
end end
end end
end end

View file

@ -48,7 +48,7 @@ module Admin
if @events.count > 0 if @events.count > 0
start_date = @events.minimum('created_at').strftime('%Y-%m-%d') start_date = @events.minimum('created_at').strftime('%Y-%m-%d')
end_date = @events.maximum('created_at').strftime('%Y-%m-%d') end_date = @events.maximum('created_at').strftime('%Y-%m-%d')
unless start_date == nil || end_date == nil unless start_date.nil? || end_date.nil?
@events_time = var_time(start_date, end_date, @events, 'created_at') @events_time = var_time(start_date, end_date, @events, 'created_at')
end end
end end
@ -87,7 +87,7 @@ module Admin
typelength += myevent.event_type.length typelength += myevent.event_type.length
@totallength += myevent.event_type.length @totallength += myevent.event_type.length
end end
if @eventstats[mytype.title] == nil if @eventstats[mytype.title].nil?
@eventstats[mytype.title] = { 'count' => events_mytype.count, @eventstats[mytype.title] = { 'count' => events_mytype.count,
'length' => events_mytype.count * mytype.length } 'length' => events_mytype.count * mytype.length }
end end
@ -187,7 +187,7 @@ module Admin
total = @conference.events.where(state: mystate).count total = @conference.events.where(state: mystate).count
status = "#{myvar.name}" status = "#{myvar.name}"
percent = 0 percent = 0 # rubocop:disable Lint/UselessAssignment
if value != 0 if value != 0
percent = (value.to_f / total * 100).round(2) percent = (value.to_f / total * 100).round(2)
result << { 'status' => status, 'value' => value, 'percent' => percent } result << { 'status' => status, 'value' => value, 'percent' => percent }

View file

@ -8,9 +8,9 @@ class Admin::SupporterLevelsController < ApplicationController
def update def update
begin begin
@conference.update_attributes!(params[:conference]) @conference.update_attributes!(params[:conference])
redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :notice => 'Supporter levels were successfully updated.') redirect_to(admin_conference_supporter_levels_path(conference_id: @conference.short_title), notice: 'Supporter levels were successfully updated.')
rescue Exception => e rescue => e
redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :alert => "Supporter levels update failed: #{e.message}") redirect_to(admin_conference_supporter_levels_path(conference_id: @conference.short_title), alert: "Supporter levels update failed: #{e.message}")
end end
end end
end end

View file

@ -10,7 +10,7 @@ class Admin::SupportersController < ApplicationController
def create def create
params[:supporter_registration][:conference_id] = @conference.id params[:supporter_registration][:conference_id] = @conference.id
supporter = SupporterRegistration.create!(params[:supporter_registration]) SupporterRegistration.create!(params[:supporter_registration])
redirect_to(admin_conference_supporters_path(:conference_id => @conference.short_title), :notice => "Supporter added") redirect_to(admin_conference_supporters_path(conference_id: @conference.short_title), notice: "Supporter added")
end end
end end

View file

@ -27,5 +27,4 @@ class Admin::VenueController < ApplicationController
@venue = @conference.venue @venue = @conference.venue
render :venue_info render :venue_info
end end
end end

View file

@ -9,7 +9,7 @@ class Admin::VolunteersController < ApplicationController
if @conference.use_vpositions if @conference.use_vpositions
@volunteers = @conference.registrations.joins(:vchoices).uniq @volunteers = @conference.registrations.joins(:vchoices).uniq
else else
@volunteers = @conference.registrations.where(:volunteer => true) @volunteers = @conference.registrations.where(volunteer: true)
end end
end end
@ -17,9 +17,9 @@ class Admin::VolunteersController < ApplicationController
@conference = Conference.find_by(short_title: params[:conference_id]) @conference = Conference.find_by(short_title: params[:conference_id])
begin begin
@conference.update_attributes!(params[:conference]) @conference.update_attributes!(params[:conference])
redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :notice => "Volunteering options were successfully updated.") redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: "Volunteering options were successfully updated.")
rescue Exception => e rescue => e
redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :alert => "Volunteering options update failed: #{e.message}") redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{e.message}")
end end
end end
end end

View file

@ -7,6 +7,6 @@ class Api::V1::ConferencesController < Api::BaseController
else else
conferences = Conference.find_all_by_guid(params[:conference_id]) conferences = Conference.find_all_by_guid(params[:conference_id])
end end
render :json => conferences, :serializer => ConferencesArraySerializer render json: conferences, serializer: ConferencesArraySerializer
end end
end end

View file

@ -70,7 +70,7 @@ class ApplicationController < ActionController::Base
rescue_from CanCan::AccessDenied do |exception| rescue_from CanCan::AccessDenied do |exception|
Rails.logger.debug("Access denied!") Rails.logger.debug("Access denied!")
redirect_to root_path, :alert => exception.message redirect_to root_path, alert: exception.message
end end
helper_method :organizer_or_admin? helper_method :organizer_or_admin?

View file

@ -68,7 +68,7 @@ class ConferenceRegistrationController < ApplicationController
else else
registration.update_attributes!(registration_params) registration.update_attributes!(registration_params)
end end
rescue Exception => e rescue => e
Rails.logger.debug e.backtrace.join('\n') Rails.logger.debug e.backtrace.join('\n')
redirect_to(register_conference_path(id: conference.short_title), redirect_to(register_conference_path(id: conference.short_title),
alert: 'Registration failed:' + e.message) alert: 'Registration failed:' + e.message)

View file

@ -1,6 +1,6 @@
class EventAttachmentsController < ApplicationController class EventAttachmentsController < ApplicationController
before_filter :verify_user before_filter :verify_user
skip_before_filter :verify_user, :only => [:show] skip_before_filter :verify_user, only: [:show]
def index def index
@proposal = Event.find(params[:proposal_id]) @proposal = Event.find(params[:proposal_id])
@ -52,8 +52,8 @@ class EventAttachmentsController < ApplicationController
if !organizer_or_admin? if !organizer_or_admin?
begin begin
event = current_user.events.find(params[:proposal_id]) current_user.events.find(params[:proposal_id])
rescue Exception => e rescue
# They certainly aren't allowed to attach a file to someone else's proposal # They certainly aren't allowed to attach a file to someone else's proposal
raise ActionController::RoutingError.new('Invalid proposal') raise ActionController::RoutingError.new('Invalid proposal')
end end
@ -67,12 +67,14 @@ class EventAttachmentsController < ApplicationController
respond_to do |format| respond_to do |format|
if @upload.save if @upload.save
format.html { format.html {
render :json => [@upload.to_jq_upload].to_json, render json: [@upload.to_jq_upload].to_json,
:content_type => 'text/html', content_type: 'text/html',
:layout => false layout: false
} }
format.json { render json: [@upload.to_jq_upload].to_json, status: :created, format.json do
location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) } render json: [@upload.to_jq_upload].to_json, status: :created,
location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload)
end
else else
format.html { render action: "new" } format.html { render action: "new" }
format.json { render json: @upload.errors, status: :unprocessable_entity } format.json { render json: @upload.errors, status: :unprocessable_entity }
@ -106,7 +108,7 @@ class EventAttachmentsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { redirect_back_or_to conference_proposal_index_path(@conference.short_title), :notice => "Deleted successfully attachment '#{@upload.title}' for proposal '#{@proposal.title}'" } format.html { redirect_back_or_to conference_proposal_index_path(@conference.short_title), notice: "Deleted successfully attachment '#{@upload.title}' for proposal '#{@proposal.title}'" }
format.json { head :no_content } format.json { head :no_content }
end end

View file

@ -23,7 +23,7 @@ class ProposalController < ApplicationController
else else
@event = Event.find(params[:id]) @event = Event.find(params[:id])
end end
rescue Exception => e rescue => e
Rails.logger.debug("Proposal failure in verify_access: #{e.message}") Rails.logger.debug("Proposal failure in verify_access: #{e.message}")
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
alert: 'Invalid or uneditable proposal.') alert: 'Invalid or uneditable proposal.')
@ -91,7 +91,7 @@ class ProposalController < ApplicationController
event.update_attributes!(params[:event]) event.update_attributes!(params[:event])
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
notice: "'#{event.title}' was successfully updated.") notice: "'#{event.title}' was successfully updated.")
rescue Exception => e rescue => e
redirect_to edit_conference_proposal_path(@conference.short_title, @event), alert: e.message redirect_to edit_conference_proposal_path(@conference.short_title, @event), alert: e.message
end end
end end
@ -131,7 +131,7 @@ class ProposalController < ApplicationController
begin begin
@event.save! @event.save!
rescue Exception => e rescue => e
@url = conference_proposal_index_path(@conference.short_title) @url = conference_proposal_index_path(@conference.short_title)
@event_types = @conference.event_types @event_types = @conference.event_types
@user = current_user @user = current_user
@ -182,7 +182,6 @@ class ProposalController < ApplicationController
end end
def restart def restart
@event
if @event.transition_possible? :restart if @event.transition_possible? :restart
begin begin
@event.restart @event.restart

View file

@ -1,9 +1,8 @@
class ScheduleController < ApplicationController class ScheduleController < ApplicationController
layout "application" layout "application"
def index def index
@conference = Conference.includes(:rooms, {:events => [:speakers, :track, :event_type]}).where("conferences.short_title" => params[:conference_id]).first @conference = Conference.includes(:rooms, {events: [:speakers, :track, :event_type]}).where("conferences.short_title" => params[:conference_id]).first
@rooms = @conference.rooms @rooms = @conference.rooms
@events = @conference.events @events = @conference.events
@dates = @conference.start_date..@conference.end_date @dates = @conference.start_date..@conference.end_date
@ -14,5 +13,4 @@ class ScheduleController < ApplicationController
@today = @conference.start_date.strftime("%Y-%m-%d") @today = @conference.start_date.strftime("%Y-%m-%d")
end end
end end
end end

View file

@ -13,7 +13,7 @@ module Users
openid = Openid.find_for_oauth(auth_hash) # Get or create openid openid = Openid.find_for_oauth(auth_hash) # Get or create openid
# If openid exists and is associated with a user, sign in with associated user, # If openid exists and is associated with a user, sign in with associated user,
# even if the email of the associated user and the email of the provided openid are different # even if the email of the associated user and the email of the provided openid are different
unless user = openid.user unless (user = openid.user)
user = User.find_for_auth(auth_hash, current_user) # Get or create users user = User.find_for_auth(auth_hash, current_user) # Get or create users
end end
@ -26,7 +26,7 @@ module Users
sign_in user sign_in user
redirect_to root_path, notice: user.email + " signed in successfully with #{provider}" redirect_to root_path, notice: user.email + " signed in successfully with #{provider}"
rescue Exception => e rescue => e
redirect_back_or_to new_user_registration_path, alert: 'Failed' + e.message redirect_back_or_to new_user_registration_path, alert: 'Failed' + e.message
end end
end end

View file

@ -75,7 +75,7 @@ module ApplicationHelper
end end
def normalize_array_length(hashmap, length) def normalize_array_length(hashmap, length)
hashmap.each do |key, value| hashmap.each do |_, value|
if value.length < length if value.length < length
value.fill(value[-1], value.length...length) value.fill(value[-1], value.length...length)
end end
@ -126,15 +126,15 @@ module ApplicationHelper
end end
def add_association_link(association_name, form_builder, div_class, html_options = {}) def add_association_link(association_name, form_builder, div_class, html_options = {})
link_to_add_association "Add " + association_name.to_s.singularize, form_builder, div_class, html_options.merge(:class => "assoc btn btn-success") link_to_add_association "Add " + association_name.to_s.singularize, form_builder, div_class, html_options.merge(class: "assoc btn btn-success")
end end
def remove_association_link(association_name, form_builder) def remove_association_link(association_name, form_builder)
link_to_remove_association("Remove " + association_name.to_s.singularize, form_builder, :class => "assoc btn btn-danger") + tag(:hr) link_to_remove_association("Remove " + association_name.to_s.singularize, form_builder, class: "assoc btn btn-danger") + tag(:hr)
end end
def dynamic_association(association_name, title, form_builder, options = {}) def dynamic_association(association_name, title, form_builder, options = {})
render "shared/dynamic_association", :association_name => association_name, :title => title, :f => form_builder, :hint => options[:hint] render "shared/dynamic_association", association_name: association_name, title: title, f: form_builder, hint: options[:hint]
end end
def has_role?(current_user, role) def has_role?(current_user, role)

View file

@ -6,7 +6,6 @@ class Mailbot < ActionMailer::Base
person.email, person.email,
conference.email_settings.registration_subject, conference.email_settings.registration_subject,
conference.email_settings.generate_registration_email(conference, person)) conference.email_settings.generate_registration_email(conference, person))
end end
def acceptance_mail(event) def acceptance_mail(event)
@ -16,7 +15,6 @@ class Mailbot < ActionMailer::Base
person.email, person.email,
conference.email_settings.accepted_subject, conference.email_settings.accepted_subject,
conference.email_settings.generate_accepted_email(event)) conference.email_settings.generate_accepted_email(event))
end end
def rejection_mail(event) def rejection_mail(event)
@ -66,11 +64,10 @@ class Mailbot < ActionMailer::Base
end end
def build_email(conference, to, subject, body) def build_email(conference, to, subject, body)
mail(:to => to, mail(to: to,
:from => conference.contact_email, from: conference.contact_email,
:reply_to => conference.contact_email, reply_to: conference.contact_email,
:subject => subject, subject: subject,
:body => body) body: body)
end end
end end

View file

@ -1,7 +1,7 @@
class Ability class Ability
include CanCan::Ability include CanCan::Ability
def initialize(user) def initialize(user) # rubocop:disable Lint/UnusedMethodArgument
# Define abilities for the passed in user here. For example: # Define abilities for the passed in user here. For example:
# #
# user ||= User.new # guest user (not logged in) # user ||= User.new # guest user (not logged in)

View file

@ -2,7 +2,7 @@ class Answer < ActiveRecord::Base
attr_accessible :title attr_accessible :title
has_many :qanswers has_many :qanswers
has_many :questions, :through => :qanswers has_many :questions, through: :qanswers
validates :title, :presence => true validates :title, presence: true
end end

View file

@ -5,7 +5,7 @@ class CallForPapers < ActiveRecord::Base
belongs_to :conference belongs_to :conference
validates_presence_of :start_date, :end_date validates_presence_of :start_date, :end_date
validates :rating, :numericality => { :greater_than_or_equal_to => 0, :less_than_or_equal_to => 10 } validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 }
## ##
# Calculates how many weeks the call for paper is. # Calculates how many weeks the call for paper is.

View file

@ -1,5 +1,5 @@
class Comment < ActiveRecord::Base class Comment < ActiveRecord::Base
acts_as_nested_set :scope => [:commentable_id, :commentable_type] acts_as_nested_set scope: [:commentable_id, :commentable_type]
attr_accessible :commentable, :body, :user_id attr_accessible :commentable, :body, :user_id
validates_presence_of :body validates_presence_of :body
validates_presence_of :user validates_presence_of :user
@ -8,7 +8,7 @@ class Comment < ActiveRecord::Base
# want user to vote on the quality of comments. # want user to vote on the quality of comments.
#acts_as_votable #acts_as_votable
belongs_to :commentable, :polymorphic => true belongs_to :commentable, polymorphic: true
# NOTE: Comments belong to a user # NOTE: Comments belong to a user
belongs_to :user belongs_to :user
@ -18,9 +18,9 @@ class Comment < ActiveRecord::Base
# example in readme # example in readme
def self.build_from(obj, user_id, comment) def self.build_from(obj, user_id, comment)
new \ new \
:commentable => obj, commentable: obj,
:body => comment, body: comment,
:user_id => user_id user_id: user_id
end end
#helper method to check if a comment has children #helper method to check if a comment has children
@ -31,13 +31,13 @@ class Comment < ActiveRecord::Base
# Helper class method to lookup all comments assigned # Helper class method to lookup all comments assigned
# to all commentable types for a given user. # to all commentable types for a given user.
scope :find_comments_by_user, lambda { |user| scope :find_comments_by_user, lambda { |user|
where(:user_id => user.id).order('created_at DESC') where(user_id: user.id).order('created_at DESC')
} }
# Helper class method to look up all comments for # Helper class method to look up all comments for
# commentable class name and commentable id. # commentable class name and commentable id.
scope :find_comments_for_commentable, lambda { |commentable_str, commentable_id| scope :find_comments_for_commentable, lambda { |commentable_str, commentable_id|
where(:commentable_type => commentable_str.to_s, :commentable_id => commentable_id).order('created_at DESC') where(commentable_type: commentable_str.to_s, commentable_id: commentable_id).order('created_at DESC')
} }
# Helper class method to look up a commentable object # Helper class method to look up a commentable object

View file

@ -89,7 +89,7 @@ class Conference < ActiveRecord::Base
format: URI::regexp(%w(http https)), allow_blank: true format: URI::regexp(%w(http https)), allow_blank: true
validates_uniqueness_of :short_title validates_uniqueness_of :short_title
validates_format_of :short_title, :with => /\A[a-zA-Z0-9_-]*\z/ validates_format_of :short_title, with: /\A[a-zA-Z0-9_-]*\z/
before_create :generate_guid before_create :generate_guid
before_create :create_venue before_create :create_venue
before_create :create_event_types before_create :create_event_types
@ -102,7 +102,6 @@ class Conference < ActiveRecord::Base
return media_types return media_types
end end
## ##
# Checks if the user is registered to the conference # Checks if the user is registered to the conference
# #
@ -640,7 +639,7 @@ class Conference < ActiveRecord::Base
# ====Returns # ====Returns
# * +Fixnum+ -> Progress in Percent # * +Fixnum+ -> Progress in Percent
def calculate_setup_progress(result) def calculate_setup_progress(result)
(result.select { |k, v| v }.length / result.length.to_f * 100).round(0).to_s (result.select { |_k, v| v }.length / result.length.to_f * 100).round(0).to_s
end end
## ##

View file

@ -9,7 +9,7 @@ class Datatable
@view = view @view = view
end end
def as_json(options = {}) def as_json
{ {
sEcho: params[:sEcho].to_i, sEcho: params[:sEcho].to_i,
iTotalRecords: @klass.count, iTotalRecords: @klass.count,
@ -18,7 +18,6 @@ class Datatable
} }
end end
def data def data
[] []
end end
@ -56,10 +55,10 @@ class Datatable
search_for = params[:sSearch].split(' ') search_for = params[:sSearch].split(' ')
terms = {} terms = {}
which_one = -1 which_one = -1
criteria = search_for.inject([]) do |criteria,atom| criteria = search_for.inject([]) do |mem, atom|
which_one += 1 which_one += 1
terms["search#{which_one}".to_sym] = "%#{atom}%" terms["search#{which_one}".to_sym] = "%#{atom}%"
criteria << "(#{search_cols.map{|col| "#{col} like :search#{which_one}"}.join(' or ')})" mem << "(#{search_cols.map{|col| "#{col} like :search#{which_one}"}.join(' or ')})"
end.join(' and ') end.join(' and ')
[criteria, terms] [criteria, terms]
end end

View file

@ -3,5 +3,4 @@ class DietaryChoice < ActiveRecord::Base
belongs_to :conference belongs_to :conference
has_many :registrations has_many :registrations
end end

View file

@ -4,5 +4,5 @@ class DifficultyLevel < ActiveRecord::Base
belongs_to :conference belongs_to :conference
has_many :events has_many :events
validates :title, :presence => true validates :title, presence: true
end end

View file

@ -197,11 +197,15 @@ class Event < ActiveRecord::Base
errors.add(:user_biography, 'must be filled out') if submitter.biography_word_count == 0 errors.add(:user_biography, 'must be filled out') if submitter.biography_word_count == 0
end end
# TODO: create a module to be mixed into model to perform same operation
# venue.rb has same functionality which can be shared
# TODO: rename guid to UUID as guid is specifically Microsoft term
def generate_guid def generate_guid
begin loop do
guid = SecureRandom.urlsafe_base64 @guid = SecureRandom.urlsafe_base64
end while self.class.where(guid: guid).exists? break if !self.class.where(guid: guid).any?
self.guid = guid end
self.guid = @guid
end end
def set_week def set_week

View file

@ -4,7 +4,7 @@ class EventAttachment < ActiveRecord::Base
belongs_to :event belongs_to :event
attr_accessible :public, :attachment, :event_id, :title attr_accessible :public, :attachment, :event_id, :title
has_attached_file :attachment, :path => ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension" has_attached_file :attachment, path: ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension"
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers
def to_jq_upload def to_jq_upload
@ -18,12 +18,9 @@ class EventAttachment < ActiveRecord::Base
"delete_url" => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id), "delete_url" => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id),
"delete_type" => "DELETE" "delete_type" => "DELETE"
} }
end end
#:path => ":rails_root/public/system/:attachment/:id/:style/:filename", #:path => ":rails_root/public/system/:attachment/:id/:style/:filename",
# :url => "/system/:attachment/:id/:style/:filename" # :url => "/system/:attachment/:id/:style/:filename"
#has_paper_trail :meta => {:associated_id => :event_id, :associated_type => "Event"} #has_paper_trail :meta => {:associated_id => :event_id, :associated_type => "Event"}
end end

View file

@ -4,7 +4,7 @@ class EventType < ActiveRecord::Base
belongs_to :conference belongs_to :conference
validates :title, presence: true validates :title, presence: true
validates :length, :numericality => {:greater_than => 0} validates :length, numericality: {greater_than: 0}
validates :minimum_abstract_length, presence: true validates :minimum_abstract_length, presence: true
validates :maximum_abstract_length, presence: true validates :maximum_abstract_length, presence: true

View file

@ -11,7 +11,7 @@ class Openid < ActiveRecord::Base
if openid.new_record? if openid.new_record?
openid.email = auth.info.email openid.email = auth.info.email
if existing_openid = Openid.where(email: openid.email).first if (existing_openid = Openid.where(email: openid.email).first)
openid.user_id = existing_openid.user_id openid.user_id = existing_openid.user_id
end end
end end

View file

@ -2,7 +2,7 @@ class Qanswer < ActiveRecord::Base
attr_accessible :question_id, :answer_id attr_accessible :question_id, :answer_id
belongs_to :question belongs_to :question
belongs_to :answer, :dependent => :delete belongs_to :answer, dependent: :delete
has_and_belongs_to_many :registrations has_and_belongs_to_many :registrations
end end

View file

@ -4,11 +4,11 @@ class Question < ActiveRecord::Base
belongs_to :question_type belongs_to :question_type
has_and_belongs_to_many :conferences has_and_belongs_to_many :conferences
has_many :qanswers, :dependent => :delete_all has_many :qanswers, dependent: :delete_all
has_many :answers, :through => :qanswers, :dependent => :delete_all has_many :answers, through: :qanswers, dependent: :delete_all
validates :title, :presence => true validates :title, presence: true
validates :answers, :presence => true validates :answers, presence: true
accepts_nested_attributes_for :answers, :allow_destroy => true accepts_nested_attributes_for :answers, allow_destroy: true
end end

View file

@ -15,5 +15,4 @@ class Room < ActiveRecord::Base
# end while Person.where(:guid => guid).exists? # end while Person.where(:guid => guid).exists?
self.guid = guid self.guid = guid
end end
end end

View file

@ -14,5 +14,4 @@ class Track < ActiveRecord::Base
# end while Person.where(:guid => guid).exists? # end while Person.where(:guid => guid).exists?
self.guid = guid self.guid = guid
end end
end end

View file

@ -4,5 +4,5 @@ class Vday < ActiveRecord::Base
belongs_to :conference belongs_to :conference
has_many :vchoices has_many :vchoices
has_many :vpositions, :through => :vchoices, :dependent => :destroy has_many :vpositions, through: :vchoices, dependent: :destroy
end end

View file

@ -11,13 +11,17 @@ class Venue < ActiveRecord::Base
content_type: [/jpg/, /jpeg/, /png/, /gif/], content_type: [/jpg/, /jpeg/, /png/, /gif/],
size: { in: 0..500.kilobytes } size: { in: 0..500.kilobytes }
accepts_nested_attributes_for :lodgings, allow_destroy: true accepts_nested_attributes_for :lodgings, allow_destroy: true
private private
# TODO: create a module to be mixed into model to perform same operation
# event.rb has same functionality which can be shared
# TODO: rename guid to UUID as guid is specifically Microsoft term
def generate_guid def generate_guid
begin loop do
guid = SecureRandom.urlsafe_base64 @guid = SecureRandom.urlsafe_base64
end while Venue.where(:guid => guid).exists? break if !Venue.where(guid: guid).any?
self.guid = guid end
self.guid = @guid
end end
end end

View file

@ -4,5 +4,4 @@ class Vote < ActiveRecord::Base
belongs_to :user belongs_to :user
belongs_to :event belongs_to :event
delegate :name, to: :user delegate :name, to: :user
end end

View file

@ -4,7 +4,7 @@ class Vposition < ActiveRecord::Base
belongs_to :conference belongs_to :conference
has_many :vchoices has_many :vchoices
has_many :vdays, :through => :vchoices has_many :vdays, through: :vchoices
validates_presence_of :title, :vdays validates_presence_of :title, :vdays
end end

View file

@ -5,7 +5,7 @@ include ActionView::Helpers::NumberHelper
if defined?(Bundler) if defined?(Bundler)
# If you precompile assets before deploying to production, use this line # If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test))) Bundler.require(*Rails.groups(assets: %w(development test)))
# If you want your assets lazily compiled in production, use this line # If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env) # Bundler.require(:default, :assets, Rails.env)
end end

View file

@ -3,4 +3,4 @@ require 'rubygems'
# Set up gems listed in the Gemfile. # Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])

View file

@ -12,7 +12,7 @@ set :repository, 'https://github.com/openSUSE/osem.git'
# They will be linked in the 'deploy:link_shared_paths' step. # They will be linked in the 'deploy:link_shared_paths' step.
set :shared_paths, %w{ config/database.yml log public/system config/secrets.yml config/config.yml tmp} set :shared_paths, %w{ config/database.yml log public/system config/secrets.yml config/config.yml tmp}
task :setup => :environment do task setup: :environment do
queue! %[mkdir -p "#{deploy_to}/shared/log"] queue! %[mkdir -p "#{deploy_to}/shared/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"] queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"]
@ -27,7 +27,7 @@ task :setup => :environment do
end end
desc 'Deploys the current version to the server.' desc 'Deploys the current version to the server.'
task :deploy => :environment do task deploy: :environment do
deploy do deploy do
invoke :'git:clone' invoke :'git:clone'
invoke :'deploy:link_shared_paths' invoke :'deploy:link_shared_paths'
@ -43,7 +43,7 @@ task :deploy => :environment do
end end
desc 'Notifies the exception handler of the deploy.' desc 'Notifies the exception handler of the deploy.'
task :notify_errbit => :environment do task notify_errbit: :environment do
revision = `git rev-parse HEAD`.strip revision = `git rev-parse HEAD`.strip
user = ENV['USER'] user = ENV['USER']
queue "bundle exec rake hoptoad:deploy TO=#{rails_env} REVISION=#{revision} REPO=#{repository} USER=#{user}" queue "bundle exec rake hoptoad:deploy TO=#{rails_env} REVISION=#{revision} REPO=#{repository} USER=#{user}"

View file

@ -5,9 +5,9 @@ require File.expand_path('../application', __FILE__)
path = Rails.root.join("config", "config.yml") path = Rails.root.join("config", "config.yml")
begin begin
CONFIG = YAML.load_file(path)[Rails.env] CONFIG = YAML.load_file(path)[Rails.env]
rescue Exception rescue
puts "Error while parsing config file #{path}" puts "Error while parsing config file #{path}"
CONFIG = Hash.new CONFIG = {}
end end
# Initialize the rails application # Initialize the rails application

View file

@ -35,6 +35,6 @@ Osem::Application.configure do
config.eager_load = false config.eager_load = false
# Set the detault url for action mailer # Set the detault url for action mailer
config.action_mailer.default_url_options = { :host => CONFIG['url_for_emails'] } config.action_mailer.default_url_options = { host: CONFIG['url_for_emails'] }
end end

View file

@ -67,5 +67,5 @@ Osem::Application.configure do
config.active_support.deprecation = :notify config.active_support.deprecation = :notify
# Set the detault url for action mailer # Set the detault url for action mailer
config.action_mailer.default_url_options = { :host => CONFIG['url_for_emails'] } config.action_mailer.default_url_options = { host: CONFIG['url_for_emails'] }
end end

View file

@ -70,7 +70,7 @@ Osem::Application.routes.draw do
patch :restart patch :restart
get :vote get :vote
end end
resource :speaker, :only => [:edit, :update] resource :speaker, only: [:edit, :update]
end end
resources :supporters resources :supporters
@ -79,11 +79,11 @@ Osem::Application.routes.draw do
resources :conference, only: [:show] do resources :conference, only: [:show] do
resources :proposal do resources :proposal do
resources :event_attachment, :controller => "event_attachments" resources :event_attachment, controller: "event_attachments"
patch '/confirm' => 'proposal#confirm' patch '/confirm' => 'proposal#confirm'
patch '/restart' => 'proposal#restart' patch '/restart' => 'proposal#restart'
end end
resource :schedule, :only => [] do resource :schedule, only: [] do
get "/" => "schedule#index" get "/" => "schedule#index"
end end
member do member do
@ -96,17 +96,17 @@ Osem::Application.routes.draw do
namespace :api, defaults: {format: 'json'} do namespace :api, defaults: {format: 'json'} do
namespace :v1 do namespace :v1 do
resources :conferences, :only => :index do resources :conferences, only: :index do
resources :conferences, :only => :index resources :conferences, only: :index
resources :rooms, :only => :index resources :rooms, only: :index
resources :tracks, :only => :index resources :tracks, only: :index
resources :speakers, :only => :index resources :speakers, only: :index
resources :events, :only => :index resources :events, only: :index
end end
resources :rooms, :only => :index resources :rooms, only: :index
resources :tracks, :only => :index resources :tracks, only: :index
resources :speakers, :only => :index resources :speakers, only: :index
resources :events, :only => :index resources :events, only: :index
end end
end end

View file

@ -2,8 +2,8 @@ class DeviseCreateUsers < ActiveRecord::Migration
def up def up
create_table(:users) do |t| create_table(:users) do |t|
## Database authenticatable ## Database authenticatable
t.string :email, :null => false, :default => "" t.string :email, null: false, default: ""
t.string :encrypted_password, :null => false, :default => "" t.string :encrypted_password, null: false, default: ""
## Recoverable ## Recoverable
t.string :reset_password_token t.string :reset_password_token
@ -13,7 +13,7 @@ class DeviseCreateUsers < ActiveRecord::Migration
t.datetime :remember_created_at t.datetime :remember_created_at
## Trackable ## Trackable
t.integer :sign_in_count, :default => 0 t.integer :sign_in_count, default: 0
t.datetime :current_sign_in_at t.datetime :current_sign_in_at
t.datetime :last_sign_in_at t.datetime :last_sign_in_at
t.string :current_sign_in_ip t.string :current_sign_in_ip
@ -36,9 +36,9 @@ class DeviseCreateUsers < ActiveRecord::Migration
t.timestamps t.timestamps
end end
add_index :users, :email, :unique => true add_index :users, :email, unique: true
add_index :users, :reset_password_token, :unique => true add_index :users, :reset_password_token, unique: true
add_index :users, :confirmation_token, :unique => true add_index :users, :confirmation_token, unique: true
# add_index :users, :unlock_token, :unique => true # add_index :users, :unlock_token, :unique => true
# add_index :users, :authentication_token, :unique => true # add_index :users, :authentication_token, :unique => true
end end

View file

@ -1,17 +1,17 @@
class CreateConferencesTable < ActiveRecord::Migration class CreateConferencesTable < ActiveRecord::Migration
def up def up
create_table :conferences do |t| create_table :conferences do |t|
t.string :guid, :null => false t.string :guid, null: false
t.string :title, :null => false t.string :title, null: false
t.string :short_title, :null => false t.string :short_title, null: false
t.string :social_tag t.string :social_tag
t.string :contact_email, :null => false t.string :contact_email, null: false
t.string :timezone, :null => false t.string :timezone, null: false
t.string :html_export_path t.string :html_export_path
t.date :start_date, :null => false t.date :start_date, null: false
t.date :end_date, :null => false t.date :end_date, null: false
t.boolean :cfp_open, :default => false t.boolean :cfp_open, default: false
t.boolean :registration_open, :default => false t.boolean :registration_open, default: false
t.references :venue t.references :venue
t.timestamps t.timestamps

View file

@ -1,12 +1,12 @@
class CreatePeopleTable < ActiveRecord::Migration class CreatePeopleTable < ActiveRecord::Migration
def up def up
create_table :people do |t| create_table :people do |t|
t.string :guid, :null => false t.string :guid, null: false
t.string :first_name, :default => "" t.string :first_name, default: ""
t.string :last_name, :default => "" t.string :last_name, default: ""
t.string :public_name, :default => "" t.string :public_name, default: ""
t.string :company, :default => "" t.string :company, default: ""
t.string :email, :null => false t.string :email, null: false
t.boolean :email_public t.boolean :email_public
t.string :avatar_file_name t.string :avatar_file_name
t.string :avatar_content_type t.string :avatar_content_type

View file

@ -1,11 +1,11 @@
class CreateRoomsTable < ActiveRecord::Migration class CreateRoomsTable < ActiveRecord::Migration
def up def up
create_table :rooms do |t| create_table :rooms do |t|
t.string :guid, :null => false t.string :guid, null: false
t.references :conference t.references :conference
t.string :name, :null => false t.string :name, null: false
t.integer :size t.integer :size
t.boolean :public, :default => true t.boolean :public, default: true
end end
end end

View file

@ -1,11 +1,11 @@
class CreateTracksTable < ActiveRecord::Migration class CreateTracksTable < ActiveRecord::Migration
def up def up
create_table :tracks do |t| create_table :tracks do |t|
t.string :guid, :null => false t.string :guid, null: false
t.references :conference t.references :conference
t.string :name, :null => false t.string :name, null: false
t.text :description t.text :description
t.string :color, :default => "#ffffff" t.string :color, default: "#ffffff"
t.timestamps t.timestamps
end end

View file

@ -1,19 +1,19 @@
class CreateEventsTable < ActiveRecord::Migration class CreateEventsTable < ActiveRecord::Migration
def up def up
create_table :events do |t| create_table :events do |t|
t.string :guid, :null => false t.string :guid, null: false
t.references :conference t.references :conference
t.references :event_type t.references :event_type
t.string :title, :null => false t.string :title, null: false
t.string :subtitle t.string :subtitle
t.integer :time_slots t.integer :time_slots
t.string :state, :null => false, :default => "new" t.string :state, null: false, default: "new"
t.string :progress, :null => false, :default => "new" t.string :progress, null: false, default: "new"
t.string :language t.string :language
t.datetime :start_time t.datetime :start_time
t.text :abstract t.text :abstract
t.text :description t.text :description
t.boolean :public, :default => true t.boolean :public, default: true
t.string :logo_file_name t.string :logo_file_name
t.string :logo_content_type t.string :logo_content_type
t.integer :logo_file_size t.integer :logo_file_size

View file

@ -2,8 +2,8 @@ class CreateEventTypes < ActiveRecord::Migration
def up def up
create_table :event_types do |t| create_table :event_types do |t|
t.references :conference t.references :conference
t.string :title, :null => false t.string :title, null: false
t.integer :length, :default => 30 t.integer :length, default: 30
end end
end end

View file

@ -4,7 +4,7 @@ class CreateEventPeopleTable < ActiveRecord::Migration
t.references :proposal t.references :proposal
t.references :person t.references :person
t.references :event t.references :event
t.string :event_role, :null => false, :default => "participant" t.string :event_role, null: false, default: "participant"
t.string :comment t.string :comment
t.timestamps t.timestamps

View file

@ -15,5 +15,4 @@ class CreateVenueTable < ActiveRecord::Migration
def down def down
drop_table :venues drop_table :venues
end end
end end

View file

@ -1,6 +1,6 @@
class UserRolesTable < ActiveRecord::Migration class UserRolesTable < ActiveRecord::Migration
def self.up def self.up
create_table :roles_users, :id => false do |t| create_table :roles_users, id: false do |t|
t.references :role, :user t.references :role, :user
end end
end end

View file

@ -1,10 +1,10 @@
class CreateCfpTable < ActiveRecord::Migration class CreateCfpTable < ActiveRecord::Migration
def up def up
create_table :call_for_papers do |t| create_table :call_for_papers do |t|
t.date :start_date, :null => false t.date :start_date, null: false
t.date :end_date, :null => false t.date :end_date, null: false
t.date :hard_deadline, :null => false t.date :hard_deadline, null: false
t.text :description, :null => false t.text :description, null: false
t.references :conference t.references :conference
t.timestamps t.timestamps

View file

@ -4,9 +4,9 @@ class CreateRegistrationsTable < ActiveRecord::Migration
t.references :person t.references :person
t.references :conference t.references :conference
t.boolean :attending_social_events, :default => true t.boolean :attending_social_events, default: true
t.boolean :attending_social_events_with_partner, :default => false t.boolean :attending_social_events_with_partner, default: false
t.boolean :using_affiliated_lodging, :default => true t.boolean :using_affiliated_lodging, default: true
t.date :arrival t.date :arrival
t.date :departure t.date :departure

View file

@ -1,9 +1,9 @@
class CreateComments < ActiveRecord::Migration class CreateComments < ActiveRecord::Migration
def self.up def self.up
create_table :comments do |t| create_table :comments do |t|
t.string :title, :limit => 50, :default => "" t.string :title, limit: 50, default: ""
t.text :comment t.text :comment
t.references :commentable, :polymorphic => true t.references :commentable, polymorphic: true
t.references :user t.references :user
t.timestamps t.timestamps
end end

View file

@ -2,12 +2,12 @@ class CreateEventAttachmentsTable < ActiveRecord::Migration
def up def up
create_table :event_attachments do |t| create_table :event_attachments do |t|
t.references :event t.references :event
t.string :title, :null => false t.string :title, null: false
t.string :attachment_file_name t.string :attachment_file_name
t.string :attachment_content_type t.string :attachment_content_type
t.integer :attachment_file_size t.integer :attachment_file_size
t.datetime :attachment_updated_at t.datetime :attachment_updated_at
t.boolean :public, :default => true t.boolean :public, default: true
t.timestamps t.timestamps
end end
end end

View file

@ -5,7 +5,7 @@ class RemoveCfpAndRegBooleansFromConferences < ActiveRecord::Migration
end end
def down def down
add_column :conferences, :cfp_open, :default => false add_column :conferences, :cfp_open, default: false
add_column :registration_open, :default => false add_column :registration_open, default: false
end end
end end

View file

@ -1,9 +1,9 @@
class CreateVersions < ActiveRecord::Migration class CreateVersions < ActiveRecord::Migration
def self.up def self.up
create_table :versions do |t| create_table :versions do |t|
t.string :item_type, :null => false t.string :item_type, null: false
t.integer :item_id, :null => false t.integer :item_id, null: false
t.string :event, :null => false t.string :event, null: false
t.string :whodunnit t.string :whodunnit
t.text :object t.text :object
t.text :object_changes t.text :object_changes

View file

@ -2,17 +2,16 @@ class CreateEmailTable < ActiveRecord::Migration
def up def up
create_table :email_settings do |t| create_table :email_settings do |t|
t.references :conference t.references :conference
t.boolean :send_on_registration, :default => true t.boolean :send_on_registration, default: true
t.boolean :send_on_accepted, :default => true t.boolean :send_on_accepted, default: true
t.boolean :send_on_rejected, :default => true t.boolean :send_on_rejected, default: true
t.boolean :send_on_confirmed_without_registration, :default => true t.boolean :send_on_confirmed_without_registration, default: true
t.text :registration_email_template t.text :registration_email_template
t.text :accepted_email_template t.text :accepted_email_template
t.text :rejected_email_template t.text :rejected_email_template
t.text :confirmed_email_template t.text :confirmed_email_template
t.timestamps t.timestamps
end end
end end
def down def down

View file

@ -1,6 +1,6 @@
class AddMinimumAndMaximumAbstractLengthsToEventTypes < ActiveRecord::Migration class AddMinimumAndMaximumAbstractLengthsToEventTypes < ActiveRecord::Migration
def change def change
add_column :event_types, :minimum_abstract_length, :integer, :default => 0 add_column :event_types, :minimum_abstract_length, :integer, default: 0
add_column :event_types, :maximum_abstract_length, :integer, :default => 500 add_column :event_types, :maximum_abstract_length, :integer, default: 500
end end
end end

View file

@ -1,5 +1,5 @@
class AddDietaryChoiceToConferences < ActiveRecord::Migration class AddDietaryChoiceToConferences < ActiveRecord::Migration
def change def change
add_column :conferences, :use_dietary_choices, :boolean, :default => false add_column :conferences, :use_dietary_choices, :boolean, default: false
end end
end end

View file

@ -2,7 +2,7 @@ class CreateDietaryChoicesTable < ActiveRecord::Migration
def up def up
create_table :dietary_choices do |t| create_table :dietary_choices do |t|
t.references :conference t.references :conference
t.string :title, :null => false t.string :title, null: false
t.timestamps t.timestamps
end end
end end

View file

@ -1,5 +1,5 @@
class AddHandicappedAccessToRegistrations < ActiveRecord::Migration class AddHandicappedAccessToRegistrations < ActiveRecord::Migration
def change def change
add_column :registrations, :handicapped_access_required, :boolean, :default => false add_column :registrations, :handicapped_access_required, :boolean, default: false
end end
end end

View file

@ -2,7 +2,7 @@ class CreateSupporterLevelTable < ActiveRecord::Migration
def up def up
create_table :supporter_levels do |t| create_table :supporter_levels do |t|
t.references :conference t.references :conference
t.string :title, :null => false t.string :title, null: false
t.string :url t.string :url
end end
end end

View file

@ -7,7 +7,7 @@ class CreateTableSupporterRegistrations < ActiveRecord::Migration
t.string :name t.string :name
t.string :email t.string :email
t.string :code t.string :code
t.boolean :code_is_valid, :default => false t.boolean :code_is_valid, default: false
end end
end end

View file

@ -1,5 +1,5 @@
class AddUseSupporterLevelsToConferences < ActiveRecord::Migration class AddUseSupporterLevelsToConferences < ActiveRecord::Migration
def change def change
add_column :conferences, :use_supporter_levels, :boolean, :default => false add_column :conferences, :use_supporter_levels, :boolean, default: false
end end
end end

View file

@ -1,6 +1,6 @@
class CreateRegistrationsSocialEventsTable < ActiveRecord::Migration class CreateRegistrationsSocialEventsTable < ActiveRecord::Migration
def up def up
create_table :registrations_social_events, :id => false do |t| create_table :registrations_social_events, id: false do |t|
t.references :registration, :social_event t.references :registration, :social_event
end end
end end

View file

@ -1,6 +1,6 @@
class SetRegistrationDefaultsToFalse < ActiveRecord::Migration class SetRegistrationDefaultsToFalse < ActiveRecord::Migration
def up def up
change_column :registrations, :using_affiliated_lodging, :boolean, :default => false change_column :registrations, :using_affiliated_lodging, :boolean, default: false
end end
def down def down

View file

@ -2,6 +2,7 @@ class ChangeAttachmentDefault < ActiveRecord::Migration
def up def up
change_column_default(:event_attachments, :public, true) change_column_default(:event_attachments, :public, true)
end end
def down def down
change_column_default(:event_attachments, :public, nil) change_column_default(:event_attachments, :public, nil)
end end

View file

@ -1,6 +1,6 @@
class CreateEventsRegistrationsTable < ActiveRecord::Migration class CreateEventsRegistrationsTable < ActiveRecord::Migration
def up def up
create_table :events_registrations, :id => false do |t| create_table :events_registrations, id: false do |t|
t.references :registration, :event t.references :registration, :event
end end
end end

View file

@ -1,5 +1,5 @@
class AddAttendedToRegistrations < ActiveRecord::Migration class AddAttendedToRegistrations < ActiveRecord::Migration
def change def change
add_column :registrations, :attended, :boolean, :default => 0 add_column :registrations, :attended, :boolean, default: 0
end end
end end

View file

@ -1,5 +1,5 @@
class AddScheduleChangesToCallForPapers < ActiveRecord::Migration class AddScheduleChangesToCallForPapers < ActiveRecord::Migration
def change def change
add_column :call_for_papers, :schedule_changes, :boolean, :default => 0 add_column :call_for_papers, :schedule_changes, :boolean, default: 0
end end
end end

View file

@ -1,5 +1,5 @@
class AddRatingToCallForPapers < ActiveRecord::Migration class AddRatingToCallForPapers < ActiveRecord::Migration
def change def change
add_column :call_for_papers, :rating, :integer, :null => 1 add_column :call_for_papers, :rating, :integer, null: 1
end end
end end

View file

@ -2,7 +2,7 @@ class CreateVpositions < ActiveRecord::Migration
def up def up
create_table :vpositions do |t| create_table :vpositions do |t|
t.references :conference t.references :conference
t.string :title, :null => false t.string :title, null: false
t.text :description t.text :description
t.timestamps t.timestamps

View file

@ -1,9 +1,9 @@
class ChangeDefaultRatingInCallForPapers < ActiveRecord::Migration class ChangeDefaultRatingInCallForPapers < ActiveRecord::Migration
def up def up
change_column :call_for_papers, :rating, :integer, :default => 3 change_column :call_for_papers, :rating, :integer, default: 3
end end
def down def down
change_column :call_for_papers, :rating, :integer, :null => 1 change_column :call_for_papers, :rating, :integer, null: 1
end end
end end

View file

@ -1,6 +1,6 @@
class RegistrationsVchoices < ActiveRecord::Migration class RegistrationsVchoices < ActiveRecord::Migration
def up def up
create_table :registrations_vchoices, :id => false do |t| create_table :registrations_vchoices, id: false do |t|
t.references :registration, :vchoice t.references :registration, :vchoice
end end
end end

View file

@ -1,6 +1,6 @@
class CreateConferencesQuestions < ActiveRecord::Migration class CreateConferencesQuestions < ActiveRecord::Migration
def change def change
create_table :conferences_questions, :id => false do |t| create_table :conferences_questions, id: false do |t|
t.references :conference t.references :conference
t.references :question t.references :question
end end

View file

@ -1,8 +1,8 @@
class CreateQanswersRegistrations < ActiveRecord::Migration class CreateQanswersRegistrations < ActiveRecord::Migration
def change def change
create_table :qanswers_registrations, :id => false do |t| create_table :qanswers_registrations, id: false do |t|
t.references :registration, :null => false t.references :registration, null: false
t.references :qanswer, :null => false t.references :qanswer, null: false
end end
end end
end end

View file

@ -4,7 +4,7 @@ class CreateDifficultyLevels < ActiveRecord::Migration
t.references :conference t.references :conference
t.string :title t.string :title
t.text :description t.text :description
t.string :color, :default => "#ffffff" t.string :color, default: "#ffffff"
t.timestamps t.timestamps
end end

View file

@ -1,5 +1,5 @@
class AddUseDifficultyLevelsToConference < ActiveRecord::Migration class AddUseDifficultyLevelsToConference < ActiveRecord::Migration
def change def change
add_column :conferences, :use_difficulty_levels, :boolean, :default => false add_column :conferences, :use_difficulty_levels, :boolean, default: false
end end
end end

View file

@ -1,11 +1,11 @@
class UseVdaysVpositionsDefaults < ActiveRecord::Migration class UseVdaysVpositionsDefaults < ActiveRecord::Migration
def up def up
change_column :conferences, :use_vpositions, :boolean, :default => false change_column :conferences, :use_vpositions, :boolean, default: false
change_column :conferences, :use_vdays, :boolean, :default => false change_column :conferences, :use_vdays, :boolean, default: false
end end
def down def down
change_column :conferences, :use_vpositions, :boolean, :default => nil change_column :conferences, :use_vpositions, :boolean, default: nil
change_column :conferences, :use_vdays, :boolean, :default => nil change_column :conferences, :use_vdays, :boolean, default: nil
end end
end end

View file

@ -30,6 +30,5 @@ class CreateEventUsers < ActiveRecord::Migration
record.comment = ep.comment record.comment = ep.comment
record.save! record.save!
end end
end end
end end

View file

@ -65,15 +65,14 @@ class AddEventsPerWeekToConference < ActiveRecord::Migration
conference.save conference.save
end end
# Cumulate the previous weeks to get a snapshot # Cumulate the previous weeks to get a snapshot
TempConference.all.each do |conference| TempConference.all.each do |conference|
hash = conference.events_per_week.sort.to_h hash = conference.events_per_week.sort.to_hash
previous = nil previous = nil
hash.each do |week, values| hash.each do |week, values|
if previous if previous
values.each do |state, value| values.each do |state, _value|
hash[week][state] += previous[state] hash[week][state] += previous[state]
end end
end end

View file

@ -5,22 +5,22 @@
# #
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first) # Mayor.create(name: 'Emanuel', city: cities.first)
Role.create(:name => "Participant") Role.create(name: "Participant")
Role.create(:name => "Organizer") Role.create(name: "Organizer")
Role.create(:name => "Admin") Role.create(name: "Admin")
qtype_yesno = QuestionType.create(:title => "Yes/No") qtype_yesno = QuestionType.create(title: "Yes/No")
qtype_single = QuestionType.create(:title => "Single Choice") QuestionType.create(title: "Single Choice")
qtype_multiple = QuestionType.create(:title => "Multiple Choice") QuestionType.create(title: "Multiple Choice")
answer_yes = Answer.create(:title => "Yes") answer_yes = Answer.create(title: "Yes")
answer_no = Answer.create(:title => "No") answer_no = Answer.create(title: "No")
questions_yes_no = ["Do you need handicapped access to the venue?", "Are you attending with partner?", "Will you attend the social event(s)?", "Will you stay at suggested hotel?"] questions_yes_no = ["Do you need handicapped access to the venue?", "Are you attending with partner?", "Will you attend the social event(s)?", "Will you stay at suggested hotel?"]
for i in questions_yes_no do questions_yes_no.each do |i|
q = Question.create(:title => i, :question_type_id => qtype_yesno.id, :global => true) q = Question.create(title: i, question_type_id: qtype_yesno.id, global: true)
Qanswer.create(:question_id => q.id, :answer_id => answer_no.id) Qanswer.create(question_id: q.id, answer_id: answer_no.id)
Qanswer.create(:question_id => q.id, :answer_id => answer_yes.id) Qanswer.create(question_id: q.id, answer_id: answer_yes.id)
end end

View file

@ -5,7 +5,8 @@ feature User do
let!(:participant_role) { create(:participant_role) } let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) } let!(:admin_role) { create(:admin_role) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
shared_examples 'admin ability' do |user|
shared_examples 'admin ability' do
scenario 'deletes a user', feature: true, js: true do scenario 'deletes a user', feature: true, js: true do
sign_in(admin) sign_in(admin)
visit admin_users_path visit admin_users_path
@ -34,6 +35,7 @@ feature User do
sign_out sign_out
end end
end end
describe 'admin' do describe 'admin' do
it_behaves_like 'admin ability', :admin it_behaves_like 'admin ability', :admin
end end

View file

@ -8,7 +8,7 @@ feature Conference do
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:conference) { create(:conference) } let(:conference) { create(:conference) }
shared_examples 'volunteer' do |user| shared_examples 'volunteer' do
scenario 'adds and updates vdays', feature: true, js: true do scenario 'adds and updates vdays', feature: true, js: true do
sign_in(admin) sign_in(admin)
visit admin_conference_volunteers_info_path( visit admin_conference_volunteers_info_path(

View file

@ -406,7 +406,7 @@ describe Conference do
end end
describe '#difficulty_levels' do describe '#difficulty_levels' do
before (:each) do before do
subject.email_settings = create(:email_settings) subject.email_settings = create(:email_settings)
@easy = create(:difficulty_level, title: 'Easy', color: '#000000') @easy = create(:difficulty_level, title: 'Easy', color: '#000000')
@hard = create(:difficulty_level, title: 'Hard', color: '#ffffff') @hard = create(:difficulty_level, title: 'Hard', color: '#ffffff')
@ -503,7 +503,7 @@ describe Conference do
end end
describe 'event type distribution' do describe 'event type distribution' do
before (:each) do before do
subject.email_settings = create(:email_settings) subject.email_settings = create(:email_settings)
@workshop = create(:event_type, title: 'Workshop', color: '#000000') @workshop = create(:event_type, title: 'Workshop', color: '#000000')
@lecture = create(:event_type, title: 'Lecture', color: '#ffffff') @lecture = create(:event_type, title: 'Lecture', color: '#ffffff')
@ -599,7 +599,7 @@ describe Conference do
end end
describe 'tracks_distribution' do describe 'tracks_distribution' do
before (:each) do before do
subject.email_settings = create(:email_settings) subject.email_settings = create(:email_settings)
@track_one = create(:track, name: 'Track One', color: '#000000') @track_one = create(:track, name: 'Track One', color: '#000000')
@track_two = create(:track, name: 'Track Two', color: '#ffffff') @track_two = create(:track, name: 'Track Two', color: '#ffffff')

Some files were not shown because too many files have changed in this diff Show more