Skip to content

Commit

Permalink
rubocop style updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Vincent committed Apr 9, 2015
1 parent d35a829 commit a83b6f8
Show file tree
Hide file tree
Showing 40 changed files with 251 additions and 563 deletions.
2 changes: 1 addition & 1 deletion Capfile
Expand Up @@ -26,4 +26,4 @@ require 'capistrano/maintenance'
require 'capistrano/rails/console'

# Load custom tasks from `lib/capistrano/tasks' if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
21 changes: 11 additions & 10 deletions Gemfile
@@ -1,6 +1,6 @@
source 'https://rubygems.org'
ruby '2.1.5'
#ruby-gemset=projectmosul
# ruby-gemset=projectmosul
# Standard Rails gems
gem 'rails', '4.2.0'
gem 'sass-rails', '5.0.1'
Expand All @@ -26,21 +26,21 @@ gem 'font-awesome-sass', '4.2.2'
# Bootstrap 3: https://github.com/twbs/bootstrap-sass
gem 'bootstrap-sass', '3.3.3'
gem 'rmagick'
gem "paperclip", "~> 4.2"
gem 'paperclip', '~> 4.2'
gem 'paper_trail', '~> 4.0.0.beta2'

gem 'dropzonejs-rails'
gem "therubyracer"
gem 'therubyracer'

#for now, until we decide if we want to use this in production or not
# for now, until we decide if we want to use this in production or not
gem 'sqlite3', '1.3.10'
gem 'dotenv-rails'
gem "less-rails"
gem "twitter-bootstrap-rails"
gem 'less-rails'
gem 'twitter-bootstrap-rails'
gem 'will_paginate'
# gem 'will_paginate-bootstrap'

gem 'sketchfably', :git => "git://github.com/neshmi/sketchfably.git"
gem 'sketchfably', git: 'git://github.com/neshmi/sketchfably.git'
gem 'newrelic_rpm'
gem 'rails_admin'

Expand All @@ -53,7 +53,7 @@ group :development, :test do
gem 'capistrano-bundler'
gem 'capistrano-rails'
gem 'capistrano-passenger'
gem 'capistrano-maintenance', github: "capistrano/maintenance", require: false
gem 'capistrano-maintenance', github: 'capistrano/maintenance', require: false
gem 'capistrano-rails-console'
gem 'byebug', '3.5.1'
gem 'web-console', '2.0.0'
Expand All @@ -74,8 +74,9 @@ group :development, :test do
gem 'factory_girl_rails'
# gem 'spring-commands-rspec'
gem 'rspec-given'
gem "codeclimate-test-reporter", require: nil
gem 'codeclimate-test-reporter', require: nil
gem 'rubocop', require: false
end

# Devise: https://github.com/plataformatec/devise
gem 'devise', '3.4.1'
gem 'devise', '3.4.1'
14 changes: 14 additions & 0 deletions Gemfile.lock
Expand Up @@ -50,6 +50,9 @@ GEM
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.0)
ast (2.0.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
autoprefixer-rails (5.1.8)
execjs
json
Expand Down Expand Up @@ -236,9 +239,12 @@ GEM
activesupport (>= 3.0.0)
cocaine (~> 0.5.3)
mime-types
parser (2.2.0.3)
ast (>= 1.1, < 3.0)
passenger (5.0.6)
rack
rake (>= 0.8.1)
powerpack (0.1.0)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
Expand Down Expand Up @@ -287,6 +293,7 @@ GEM
activesupport (= 4.2.0)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
rake (10.4.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
Expand Down Expand Up @@ -320,6 +327,12 @@ GEM
rspec-mocks (~> 3.2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
rubocop (0.30.0)
astrolabe (~> 1.3)
parser (>= 2.2.0.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.7.5)
ruby_parser (3.6.5)
sexp_processor (~> 4.1)
Expand Down Expand Up @@ -429,6 +442,7 @@ DEPENDENCIES
rmagick
rspec-given
rspec-rails (~> 3.0)
rubocop
sass-rails (= 5.0.1)
shoulda-matchers
sketchfably!
Expand Down
14 changes: 7 additions & 7 deletions Guardfile
Expand Up @@ -32,8 +32,8 @@
# * zeus: 'zeus rspec' (requires the server to be started separately)
# * 'just' rspec: 'rspec'

guard :rspec, cmd: "CODECLIMATE_REPO_TOKEN=aeb04acac09c4d54f78fcf18eb574f1805129a5b5c81735f6dd85f4c7800a35e bundle exec rspec" do
require "guard/rspec/dsl"
guard :rspec, cmd: 'CODECLIMATE_REPO_TOKEN=aeb04acac09c4d54f78fcf18eb574f1805129a5b5c81735f6dd85f4c7800a35e bundle exec rspec' do
require 'guard/rspec/dsl'
dsl = Guard::RSpec::Dsl.new(self)

# Feel free to open issues for suggestions and improvements
Expand All @@ -55,9 +55,9 @@ guard :rspec, cmd: "CODECLIMATE_REPO_TOKEN=aeb04acac09c4d54f78fcf18eb574f1805129

watch(rails.controllers) do |m|
[
rspec.spec.("routing/#{m[1]}_routing"),
rspec.spec.("controllers/#{m[1]}_controller"),
rspec.spec.("acceptance/#{m[1]}")
rspec.spec.call("routing/#{m[1]}_routing"),
rspec.spec.call("controllers/#{m[1]}_controller"),
rspec.spec.call("acceptance/#{m[1]}")
]
end

Expand All @@ -67,12 +67,12 @@ guard :rspec, cmd: "CODECLIMATE_REPO_TOKEN=aeb04acac09c4d54f78fcf18eb574f1805129
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }

# Capybara features specs
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }

# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
end
end

Expand Down
38 changes: 18 additions & 20 deletions app/controllers/application_controller.rb
Expand Up @@ -6,27 +6,28 @@ class ApplicationController < ActionController::Base
before_filter :configure_permitted_parameters, if: :devise_controller?
before_filter :reject_locked!, if: :devise_controller?


# Devise permitted params
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(
:username,
:email,
:password,
:password_confirmation)
}
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(
:username,
:email,
:password,
:password_confirmation,
:current_password
devise_parameter_sanitizer.for(:sign_up) do |u|
u.permit(
:username,
:email,
:password,
:password_confirmation)
end
devise_parameter_sanitizer.for(:account_update) do |u|
u.permit(
:username,
:email,
:password,
:password_confirmation,
:current_password
)
}
end
end

# Redirects on successful sign in
def after_sign_in_path_for(resource)
def after_sign_in_path_for(_resource)
root_path
end

Expand All @@ -36,7 +37,7 @@ def reject_locked!
sign_out current_user
user_session = nil
current_user = nil
flash[:alert] = "Your account is locked."
flash[:alert] = 'Your account is locked.'
flash[:notice] = nil
redirect_to root_url
end
Expand All @@ -47,10 +48,7 @@ def reject_locked!
def require_admin!
authenticate_user!

if current_user && !current_user.admin?
redirect_to root_path
end
redirect_to root_path if current_user && !current_user.admin?
end
helper_method :require_admin!

end
33 changes: 17 additions & 16 deletions app/controllers/artefacts_controller.rb
@@ -1,12 +1,12 @@
class ArtefactsController < ApplicationController
before_action :set_artefact, only: [:show, :edit, :update, :destroy]
before_filter :require_admin!, only: [:destroy]
before_filter :authenticate_user!, :except => [:show, :index]
before_filter :authenticate_user!, except: [:show, :index]

# GET /artefacts
# GET /artefacts.json
def index
@artefacts = Artefact.paginate(:page => params[:page])
@artefacts = Artefact.paginate(page: params[:page])
end

# GET /artefacts/1
Expand All @@ -32,15 +32,15 @@ def create

if params[:images]
# The magic is here ;)
params[:images].each { |image|
params[:images].each do |image|
@artefact.images.create(image: image)
}
end
end

format.html { redirect_to @artefact, notice: 'Artefact was successfully created.' }
format.json { render json: @artefact, status: :created, location: @artefact }
else
format.html { render action: "new" }
format.html { render action: 'new' }
format.json { render json: @artefact.errors, status: :unprocessable_entity }
end
end
Expand All @@ -55,14 +55,14 @@ def update
if @artefact.update_attributes(artefact_params)
if params[:images]
# The magic is here ;)
params[:images].each { |image|
params[:images].each do |image|
@artefact.images.create(image: image)
}
end
end
format.html { redirect_to @artefact, notice: 'Asset was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.html { render action: 'edit' }
format.json { render json: @artefact.errors, status: :unprocessable_entity }
end
end
Expand All @@ -79,13 +79,14 @@ def destroy
end

private
# Use callbacks to share common setup or constraints between actions.
def set_artefact
@artefact = Artefact.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def artefact_params
params.require(:artefact).permit(:name, :description, :museum_identifier, :images)
end
# Use callbacks to share common setup or constraints between actions.
def set_artefact
@artefact = Artefact.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def artefact_params
params.require(:artefact).permit(:name, :description, :museum_identifier, :images)
end
end
32 changes: 15 additions & 17 deletions app/controllers/assets_controller.rb
@@ -1,10 +1,9 @@
class AssetsController < ApplicationController
before_filter :require_admin!, only: [:destroy]
before_filter :authenticate_user!, :except => [:show, :index]
before_filter :authenticate_user!, except: [:show, :index]
# GET /assets
# GET /assets.json
def index

@artefact = Artefact.find(params[:artefact_id])

@assets = @artefact.assets
Expand Down Expand Up @@ -40,7 +39,7 @@ def new

# GET /assets/1/edit
def edit
#@artefact = Artefact.find(params[:artefact_id])
# @artefact = Artefact.find(params[:artefact_id])

@asset = Asset.find(params[:id])
# @asset = Asset.find(params[:id])
Expand All @@ -53,24 +52,23 @@ def create

if @asset.save
respond_to do |format|
format.html {
render :json => [@asset.to_jq_upload].to_json,
:content_type => 'text/html',
:layout => false
}
format.json {
render :json => [@asset.to_jq_upload].to_json
}
format.html do
render json: [@asset.to_jq_upload].to_json,
content_type: 'text/html',
layout: false
end
format.json do
render json: [@asset.to_jq_upload].to_json
end
end
else
render :json => [{:error => "custom_failure"}], :status => 304
render json: [{ error: 'custom_failure' }], status: 304
end
end

# PUT /assets/1
# PUT /assets/1.json
def update

@artefact = Artefact.find(params[:artefact_id])

@asset = @artefact.assets.find(params[:id])
Expand All @@ -80,7 +78,7 @@ def update
format.html { redirect_to artefact_path(@artefact), notice: 'Asset was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.html { render action: 'edit' }
format.json { render json: @asset.errors, status: :unprocessable_entity }
end
end
Expand All @@ -89,8 +87,8 @@ def update
# DELETE /assets/1
# DELETE /assets/1.json
def destroy
#@artefact = Artefact.find(params[:artefact_id])
#@asset = @artefact.assets.find(params[:id])
# @artefact = Artefact.find(params[:artefact_id])
# @asset = @artefact.assets.find(params[:id])
@asset = Asset.find(params[:id])
@asset.destroy

Expand All @@ -117,4 +115,4 @@ def make_default
def asset_params
params.require(:asset).permit(:artefact_id, :image)
end
end
end

0 comments on commit a83b6f8

Please sign in to comment.