Skip to content

Commit

Permalink
Testing on supported version of rails. Fixes #135
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed May 23, 2017
1 parent 4eff2e7 commit c4309e0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jdk:
- oraclejdk8
env:
matrix:
- "RAILS_VERSION=4.2.7"
- "RAILS_VERSION=5.0.0"
- "RAILS_VERSION=5.1.1"
- "RAILS_VERSION=5.0.3"
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
1 change: 1 addition & 0 deletions hydra-editor.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Gem::Specification.new do |s|

s.add_development_dependency 'sqlite3', '~> 1.3'
s.add_development_dependency 'rspec-rails', '~> 3.1'
s.add_development_dependency 'rails-controller-testing'
s.add_development_dependency 'factory_girl_rails', '~> 4.2'
s.add_development_dependency "capybara", '~> 2.4'
s.add_development_dependency "devise", '~> 4.0'
Expand Down
30 changes: 15 additions & 15 deletions spec/controllers/records_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
expect(response).to render_template(:choose_type)
end
it 'should be successful' do
get :new, type: 'Audio'
get :new, params: { type: 'Audio' }
expect(response).to be_successful
expect(response).to render_template(:new)
end
Expand All @@ -38,20 +38,20 @@
end

it 'should be successful' do
post :create, type: 'Audio', audio: { title: ['My title'] }
post :create, params: { type: 'Audio', audio: { title: ['My title'] } }
expect(response).to redirect_to("/catalog/#{assigns[:record].id}")
expect(assigns[:record].title).to eq ['My title']
end

it "should not set attributes that aren't listed in terms_for_editing" do
# params[:audio][:collection_id] would be a good test, but that doesn't work in ActiveFedora 6.7
post :create, type: 'Audio', audio: { isPartOf: 'my collection' }
post :create, params: { type: 'Audio', audio: { isPartOf: 'my collection' } }
expect(response).to redirect_to("/catalog/#{assigns[:record].id}")
expect(assigns[:record].isPartOf).to eq []
end

it 'should be successful with json' do
post :create, type: 'Audio', audio: { title: ['My title'] }, format: :json
post :create, params: { type: 'Audio', audio: { title: ['My title'] } }, format: :json
expect(response.status).to eq 201
end

Expand All @@ -61,7 +61,7 @@
controller.current_ability.can :create, Audio
end
it 'should be successful' do
post :create, type: 'Audio', audio: { title: ['My title'] }
post :create, params: { type: 'Audio', audio: { title: ['My title'] } }
expect(response).to redirect_to("/catalog/#{assigns[:record].id}")
expect(assigns[:record].title).to eq ['My title']
end
Expand All @@ -78,7 +78,7 @@ def set_attributes
before { allow(controller).to receive(:resource_instance_name).and_return('record') }

it 'should run set_attributes' do
post :create, type: 'Audio', audio: { title: ['My title'] }
post :create, params: { type: 'Audio', audio: { title: ['My title'] } }
expect(response).to redirect_to("/catalog/#{assigns[:record].id}")
expect(assigns[:record].creator).to eq ['Fleece Vest']
end
Expand All @@ -90,7 +90,7 @@ def set_attributes
end

it 'should run object_as_json' do
post :create, type: 'Audio', audio: { title: ['My title'] }, format: 'json'
post :create, params: { type: 'Audio', audio: { title: ['My title'] } }, format: 'json'
expect(JSON.parse(response.body)).to eq('message' => 'it works')
expect(response.code).to eq '201'
end
Expand All @@ -99,7 +99,7 @@ def set_attributes
describe 'when redirect_after_create is overridden' do
it 'should redirect to the alternate location' do
allow(controller).to receive(:redirect_after_create).and_return('/')
post :create, type: 'Audio', audio: { title: ['My title'] }
post :create, params: { type: 'Audio', audio: { title: ['My title'] } }
expect(response).to redirect_to('/')
end
end
Expand All @@ -110,7 +110,7 @@ def set_attributes
expect(stub_audio).to receive(:save).and_return(false)
end
it 'should draw the form' do
post :create, type: 'Audio', audio: { title: ['My title'] }
post :create, params: { type: 'Audio', audio: { title: ['My title'] } }
expect(response).to render_template('records/new')
expect(assigns[:form].title).to eq ['My title']
expect(assigns[:form].description).to eq ['']
Expand All @@ -127,7 +127,7 @@ def set_attributes
end

it 'should be successful' do
get :edit, id: audio
get :edit, params: { id: audio }
expect(response).to be_successful
expect(assigns[:record].title).to eq ['My title2']
end
Expand All @@ -147,7 +147,7 @@ def set_attributes
end

it 'should draw the form' do
put :update, id: audio, audio: { title: ['My title 3'] }
put :update, params: { id: audio, audio: { title: ['My title 3'] } }
expect(response).to be_successful
expect(response).to render_template('records/edit')
expect(assigns[:form].title).to eq ['My title 3']
Expand All @@ -161,20 +161,20 @@ def set_attributes
end

it 'should be successful' do
put :update, id: audio, audio: { title: ['My title 3'] }
put :update, params: { id: audio, audio: { title: ['My title 3'] } }
expect(response).to redirect_to("/catalog/#{assigns[:record].id}")
expect(assigns[:record].title).to eq ['My title 3']
end

it 'should be successful with json' do
put :update, id: audio, audio: { title: ['My title'] }, format: :json
put :update, params: { id: audio, audio: { title: ['My title'] } }, format: :json
expect(response.status).to eq 204
end

context 'when redirect_after_update is overridden' do
it 'should redirect to the alternate location' do
allow(controller).to receive(:redirect_after_update).and_return('/')
put :update, id: audio, audio: { title: ['My title 3'] }
put :update, params: { id: audio, audio: { title: ['My title 3'] } }
expect(response).to redirect_to('/')
end
end
Expand All @@ -191,7 +191,7 @@ def set_attributes

describe 'who goes to the new page' do
it 'should not be allowed' do
get :new, type: 'Audio'
get :new, params: { type: 'Audio' }
expect(response).to redirect_to '/'
expect(flash[:alert]).to eq 'You are not authorized to access this page.'
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'engine_cart'
EngineCart.load_application!

require 'rails-controller-testing'
require 'rspec/rails'
require 'factory_girl_rails'

Expand Down

0 comments on commit c4309e0

Please sign in to comment.