Skip to content

Commit

Permalink
fixed rubocop errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Singh committed Jun 15, 2016
1 parent ee4581d commit d36b573
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 18 deletions.
5 changes: 2 additions & 3 deletions app/controllers/challenges_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class ChallengesController < ApplicationController
before_action :enforce_access
before_action :find_challenge, except: :index

def index
@categories = @game.categories.includes(:challenges).order(:name)
@challenges = @game.challenges
Expand All @@ -17,7 +16,7 @@ def show
is_admin = current_user.is_a?(Admin)
# Accept the flag via GET request if the current user is an admin.
@admin_flag = Flag.find(params[:flag]) if is_admin && params[:flag]
@solved = @challenge.is_solved_by_user?(current_user)
@solved = @challenge.solved_by_user?(current_user)
@solved_video_url = @challenge.get_video_url_for_flag(current_user)
# Get video URL for admins
@solved_video_url = @admin_flag.video_url if @admin_flag
Expand All @@ -26,7 +25,7 @@ def show
flash.now[:success] = 'Flag accepted!' if @solved || @admin_flag
@title = @challenge.name
@subtitle = pluralize(@challenge.point_value, 'point')
@submitted_flags = to_timeline SubmittedFlag.where('challenge_id=?', params[:id]).group_by
@submitted_flags = to_timeline SubmittedFlag.where('challenge_id=?', params[:id]).group_by
{ |sf| sf.updated_at.change(sec: 0) }
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/challenge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def force_closed?(division)
end

def get_current_solved_challenge(user)
solved_challenge = SolvedChallenge.where('challenge_id = :challenge and user_id = :user',
solved_challenge = SolvedChallenge.where('challenge_id = :challenge and user_id = :user',
challenge: self, user: user)
solved_challenge.first unless solved_challenge.nil?
end

def is_solved_by_user?(user)
def solved_by_user?(user)
!get_current_solved_challenge(user).nil?
end

Expand Down
6 changes: 3 additions & 3 deletions app/views/challenges/_gameboard.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
- if is_admin
- is_solved = challenge.is_solved?
- else
- is_solved = challenge.is_solved_by_user?(current_user)
- is_solved = challenge.solved_by_user?(current_user)
- if challenge.force_closed?(division) && challenge.is_solved?
- style << "color:DarkOrange;"
- style << "color:DarkOrange;"
- elsif challenge.force_closed?(division)
- style << "color:red;"
- elsif is_solved
- style << "color:#08C;"
- elsif challenge.open?(division) || (is_admin && challenge.challenge_open?(division))
- style << "color:green;"
- else
- style << "color:gray;"
- style << "color:gray;"
%td{ style: style }= link_to_if (is_admin || challenge.open?(division)), challenge.point_value, challenge, style: "color:inherit;"
- else
%td &nbsp;
3 changes: 2 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"

# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# Precompile additional assets (application.js, application.css,
# and all non-JS/CSS are already added)
# config.assets.precompile += %w( search.js )

# Disable delivery errors, bad email addresses will be ignored
Expand Down
6 changes: 3 additions & 3 deletions config/initializers/backtrace_silencers.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Be sure to restart your server when you modify this file.

# You can add backtrace silencers for libraries that you're using but
# You can add backtrace silencers for libraries that you're using but
# don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }

# You can also remove all the silencers if you're trying to debug a problem that might stem
# from framework code.
# You can also remove all the silencers if you're trying to debug a problem that might stem
# from framework code.
# Rails.backtrace_cleaner.remove_silencers!
3 changes: 2 additions & 1 deletion lib/tasks/cucumber.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gems:* tasks

vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib')
unless vendored_cucumber_bin.nil?

begin
require 'cucumber/rake/task'
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/scoreboard.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace :scoreboard do
task :add, [:player_login, :player, :password] => [:environment] do |_t, args|
p = Game.instance.players.find_by_email((args[:player_login]).to_s)
if p.nil?
p = Player.new(email: to_s(args[:player_login]), password: to_s(args[:password]), game_id:
p = Player.new(email: to_s(args[:player_login]), password: to_s(args[:password]), game_id:
Game.instance.id)
p.display_name = to_s(args[:player])
p.save!
Expand Down Expand Up @@ -74,7 +74,7 @@ namespace :scoreboard do
namespace :certificates do
desc 'Sync user certificates between scoreboard and VPN box'
task copy: [:environment] do
system "/usr/bin/unison -auto -batch -ignorearchives /opt/keys
system "/usr/bin/unison -auto -batch -ignorearchives /opt/keys
ssh://#{Rails.configuration.jumpbox[:ip]}//opt/openvpn_keys"
end
end
Expand Down
4 changes: 2 additions & 2 deletions script/rails
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3
# This command will automatically be run when you run "rails" with Rails 3
gems installed from the root of your application.

APP_PATH = File.expand_path('../../config/application', __FILE__)
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
3 changes: 2 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

class ActiveSupport::TestCase
class ActiveSupport
class TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all

Expand Down

0 comments on commit d36b573

Please sign in to comment.