Fix Hound CI violations

This commit is contained in:
Chrisbr 2014-05-10 10:24:58 +02:00
parent 0661b86b1c
commit 546977fc02
3 changed files with 26 additions and 19 deletions

View file

@ -16,9 +16,10 @@ class Admin::ConferenceController < ApplicationController
def create def create
@conference = Conference.new(params[:conference]) @conference = Conference.new(params[:conference])
if @conference.save if @conference.save
redirect_to(admin_conference_path(:id => @conference.short_title), :notice => 'Conference was successfully created.') redirect_to(admin_conference_path(id: @conference.short_title),
notice: 'Conference was successfully created.')
else else
render :action => "new" render action: 'new'
end end
end end
@ -26,9 +27,11 @@ class Admin::ConferenceController < ApplicationController
@conference = Conference.find_by(short_title: params[:id]) @conference = Conference.find_by(short_title: params[:id])
short_title = @conference.short_title short_title = @conference.short_title
if @conference.update_attributes(params[:conference]) if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_path(id: @conference.short_title), notice: 'Conference was successfully updated.') redirect_to(admin_conference_path(id: @conference.short_title),
notice: 'Conference was successfully updated.')
else else
redirect_to(admin_conference_path(id: short_title), notice: 'Conference update failed.') redirect_to(admin_conference_path(id: short_title),
notice: 'Conference update failed.')
end end
end end
@ -37,7 +40,7 @@ class Admin::ConferenceController < ApplicationController
@conference = Conference.find_by(short_title: params[:id]) @conference = Conference.find_by(short_title: params[:id])
respond_to do |format| respond_to do |format|
format.html format.html
format.json { render :json => @conference.to_json } format.json { render json: @conference.to_json }
end end
end end
end end

View file

@ -59,10 +59,11 @@ describe Admin::ConferenceController do
describe 'POST #create' do describe 'POST #create' do
context 'with valid attributes' do context 'with valid attributes' do
it 'saves the conference to the database' do it 'saves the conference to the database' do
expect { expected = expect do
post :create, conference: post :create, conference:
attributes_for(:conference, short_title: 'dps15') attributes_for(:conference, short_title: 'dps15')
}.to change(Conference, :count).by(1) end
expected.to change { Conference.count }.by 1
end end
it 'redirects to conference#show' do it 'redirects to conference#show' do
@ -76,10 +77,11 @@ describe Admin::ConferenceController do
context 'with invalid attributes' do context 'with invalid attributes' do
it 'does not save the conference to the database' do it 'does not save the conference to the database' do
expect { expected = expect do
post :create, conference: post :create, conference:
attributes_for(:conference, short_title: nil) attributes_for(:conference, short_title: nil)
}.to_not change(Conference, :count) end
expected.to_not change { Conference.count }
end end
it 're-renders the new template' do it 're-renders the new template' do
@ -91,9 +93,11 @@ describe Admin::ConferenceController do
context 'with duplicate conference short title' do context 'with duplicate conference short title' do
it 'does not save the conference to the database' do it 'does not save the conference to the database' do
expect { expected = expect do
post :create, conference: attributes_for(:conference) post :create, conference:
}.to_not change(Conference, :count) attributes_for(:conference)
end
expected.to_not change { Conference.count }
end end
it 're-renders the new template' do it 're-renders the new template' do

View file

@ -1,8 +1,8 @@
require 'coveralls' require 'coveralls'
Coveralls.wear!('rails') Coveralls.wear!('rails')
# This file is copied to spec/ when you run 'rails generate rspec:install' # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test' ENV['RAILS_ENV'] ||= 'test'
require File.expand_path("../../config/environment", __FILE__) require File.expand_path('../../config/environment', __FILE__)
if Rails.configuration.database_configuration['test']['database'] == ':memory:' if Rails.configuration.database_configuration['test']['database'] == ':memory:'
load "#{Rails.root}/db/schema.rb" load "#{Rails.root}/db/schema.rb"
@ -18,7 +18,7 @@ require 'rspec/rails'
# run twice. It is recommended that you do not name files matching this glob to # run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with with the --pattern # end with _spec.rb. You can configure this pattern with with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
RSpec.configure do |config| RSpec.configure do |config|
# ## Mock Framework # ## Mock Framework
@ -41,16 +41,16 @@ RSpec.configure do |config|
# order dependency and want to debug it, you can fix the order by providing # order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run. # the seed, which is printed after each run.
# --seed 1234 # --seed 1234
config.order = "random" config.order = 'random'
# Include factory_girls syntax # Include factory_girls syntax
config.include FactoryGirl::Syntax::Methods config.include FactoryGirl::Syntax::Methods
# Enables devise sign_in function
config.include Devise::TestHelpers, type: :controller
# As we start from scratch in April 2014, let's forbid the old :should syntax # As we start from scratch in April 2014, let's forbid the old :should syntax
config.expect_with :rspec do |c| config.expect_with :rspec do |c|
c.syntax = :expect c.syntax = :expect
# Enables devise sign_in function
config.include Devise::TestHelpers, type: :controller
end end
end end