diff --git a/app/controllers/admin/conference_controller.rb b/app/controllers/admin/conference_controller.rb index 7e0dd3c8..70e56897 100644 --- a/app/controllers/admin/conference_controller.rb +++ b/app/controllers/admin/conference_controller.rb @@ -16,9 +16,10 @@ class Admin::ConferenceController < ApplicationController def create @conference = Conference.new(params[:conference]) 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 - render :action => "new" + render action: 'new' end end @@ -26,9 +27,11 @@ class Admin::ConferenceController < ApplicationController @conference = Conference.find_by(short_title: params[:id]) short_title = @conference.short_title 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 - 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 @@ -37,7 +40,7 @@ class Admin::ConferenceController < ApplicationController @conference = Conference.find_by(short_title: params[:id]) respond_to do |format| format.html - format.json { render :json => @conference.to_json } + format.json { render json: @conference.to_json } end end end diff --git a/spec/controllers/conferences_controller_spec.rb b/spec/controllers/conferences_controller_spec.rb index ae364027..e53462aa 100644 --- a/spec/controllers/conferences_controller_spec.rb +++ b/spec/controllers/conferences_controller_spec.rb @@ -59,10 +59,11 @@ describe Admin::ConferenceController do describe 'POST #create' do context 'with valid attributes' do it 'saves the conference to the database' do - expect { + expected = expect do post :create, conference: attributes_for(:conference, short_title: 'dps15') - }.to change(Conference, :count).by(1) + end + expected.to change { Conference.count }.by 1 end it 'redirects to conference#show' do @@ -76,10 +77,11 @@ describe Admin::ConferenceController do context 'with invalid attributes' do it 'does not save the conference to the database' do - expect { + expected = expect do post :create, conference: attributes_for(:conference, short_title: nil) - }.to_not change(Conference, :count) + end + expected.to_not change { Conference.count } end it 're-renders the new template' do @@ -91,9 +93,11 @@ describe Admin::ConferenceController do context 'with duplicate conference short title' do it 'does not save the conference to the database' do - expect { - post :create, conference: attributes_for(:conference) - }.to_not change(Conference, :count) + expected = expect do + post :create, conference: + attributes_for(:conference) + end + expected.to_not change { Conference.count } end it 're-renders the new template' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ec20a169..33a10083 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,8 +1,8 @@ require 'coveralls' Coveralls.wear!('rails') # This file is copied to spec/ when you run 'rails generate rspec:install' -ENV["RAILS_ENV"] ||= 'test' -require File.expand_path("../../config/environment", __FILE__) +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../../config/environment', __FILE__) if Rails.configuration.database_configuration['test']['database'] == ':memory:' 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 # 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`. -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| # ## Mock Framework @@ -41,16 +41,16 @@ RSpec.configure do |config| # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 - config.order = "random" + config.order = 'random' # Include factory_girls syntax 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 config.expect_with :rspec do |c| c.syntax = :expect - - # Enables devise sign_in function - config.include Devise::TestHelpers, type: :controller end end