Skip to content

Commit

Permalink
Fix deprecations with rails5-spec-converter
Browse files Browse the repository at this point in the history
  • Loading branch information
tjgrathwell committed Mar 1, 2017
1 parent 54e3c44 commit 542dc15
Show file tree
Hide file tree
Showing 26 changed files with 231 additions and 221 deletions.
2 changes: 1 addition & 1 deletion spec/controllers/chapters/leaders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

non_leader = create(:user, first_name: 'Steve')

get :potential, format: :json, chapter_id: chapter.id, q: 'Steve'
get :potential, params: { chapter_id: chapter.id, q: 'Steve' }, format: :json

expect(JSON.parse(response.body).map { |u| u['id'] }).to eq([non_leader.id])
end
Expand Down
14 changes: 7 additions & 7 deletions spec/controllers/chapters_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

describe 'as an admin' do
it 'shows all events' do
get :show, id: chapter.id
get :show, params: { id: chapter.id }
expect(assigns(:chapter_events)).to match_array([@draft_event, @pending_event, @published_event])
end
end
Expand All @@ -38,7 +38,7 @@
let(:user) { create(:user) }

it 'shows a list of published events' do
get :show, id: chapter.id
get :show, params: { id: chapter.id }
expect(assigns(:chapter_events)).to match_array([@published_event])
end
end
Expand All @@ -54,7 +54,7 @@
describe '#create' do
it 'creates a new chapter' do
expect {
post :create, chapter: {name: "Fabulous Chapter", organization_id: organization.id}
post :create, params: {chapter: {name: "Fabulous Chapter", organization_id: organization.id}}
}.to change(Chapter, :count).by(1)
end
end
Expand All @@ -63,7 +63,7 @@
let!(:chapter) { create(:chapter) }

it "shows a chapter edit form" do
get :edit, id: chapter.id
get :edit, params: { id: chapter.id }
expect(response).to be_success
end
end
Expand All @@ -73,7 +73,7 @@

it "changes chapter details" do
expect {
put :update, id: chapter.id, chapter: {name: 'Sandwich Chapter'}
put :update, params: {id: chapter.id, chapter: {name: 'Sandwich Chapter'}}
}.to change { chapter.reload.name }
expect(response).to redirect_to(chapter_path(chapter))
end
Expand All @@ -84,14 +84,14 @@

it "can delete a chapter that belongs to no events" do
expect {
delete :destroy, {id: chapter.id}
delete :destroy, params: {id: chapter.id}
}.to change(Chapter, :count).by(-1)
end

it "cannot delete a chapter that belongs to a event" do
create(:event, chapter: chapter)
expect {
delete :destroy, {id: chapter.id}
delete :destroy, params: {id: chapter.id}
}.not_to change(Chapter, :count)
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/checkiners_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
end

it "can see list of checkiners" do
get :index, event_id: @event.id
get :index, params: { event_id: @event.id }
expect(response).to be_success
end

describe "assigning checkiners" do
it "can promote a user to checkiner" do
other_user_rsvp = create(:rsvp, event: @event)
expect {
post :create, event_id: @event.id, event_checkiner: {rsvp_id: other_user_rsvp.id}
post :create, params: {event_id: @event.id, event_checkiner: {rsvp_id: other_user_rsvp.id}}
}.to change { other_user_rsvp.reload.checkiner }
expect(response).to redirect_to(event_checkiners_path(@event))
end

it "shows an error if no user is provided" do
post :create, event_id: @event.id
post :create, params: { event_id: @event.id }
expect(assigns(:event).errors[:base].length).to be >= 1
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/checkins_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

describe "GET index" do
it "succeeds" do
get :index, event_id: @event.id, event_session_id: @session.id
get :index, params: { event_id: @event.id, event_session_id: @session.id }
expect(response).to be_success
end

it "assigns the event and session" do
get :index, event_id: @event.id, event_session_id: @session.id
get :index, params: { event_id: @event.id, event_session_id: @session.id }
expect(assigns(:event)).to eq(@event)
expect(assigns(:session)).to eq(@session)
end
Expand All @@ -34,7 +34,7 @@

it "checks in the volunteer and returns the number of checked-in persons" do
expect {
post :create, event_id: @event.id, event_session_id: @session.id, rsvp_session: { id: @rsvp_session.id }
post :create, params: { event_id: @event.id, event_session_id: @session.id, rsvp_session: { id: @rsvp_session.id } }
}.to change { @rsvp_session.reload.checked_in? }.from(false).to(true)

expect(JSON.parse(response.body).as_json).to eq(JSON.parse({
Expand All @@ -61,7 +61,7 @@

it "removes checked-in status for the volunteer and returns the number of checked-in persons" do
expect {
delete :destroy, event_id: @event.id, event_session_id: @session.id, id: @rsvp_session.id, rsvp_session: { id: @rsvp_session.id }
delete :destroy, params: { event_id: @event.id, event_session_id: @session.id, id: @rsvp_session.id, rsvp_session: { id: @rsvp_session.id } }
}.to change { @rsvp_session.reload.checked_in? }.from(true).to(false)

expect(JSON.parse(response.body).as_json).to eq(JSON.parse({
Expand Down
28 changes: 14 additions & 14 deletions spec/controllers/courses_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@

describe "GET #new" do
it "assigns a new course as @course" do
get :new, {}, valid_session
get :new, params: {}, session: valid_session
expect(assigns(:course)).to be_a_new(Course)
end
end

describe "GET #edit" do
it "assigns the requested course as @course" do
course = Course.create! valid_attributes
get :edit, {id: course.to_param}, valid_session
get :edit, params: {id: course.to_param}, session: valid_session
expect(assigns(:course)).to eq(course)
end
end
Expand All @@ -44,30 +44,30 @@
context "with valid params" do
it "creates a new Course" do
expect {
post :create, {course: valid_attributes}, valid_session
post :create, params: {course: valid_attributes}, session: valid_session
}.to change(Course, :count).by(1)
end

it "assigns a newly created course as @course" do
post :create, {course: valid_attributes}, valid_session
post :create, params: {course: valid_attributes}, session: valid_session
expect(assigns(:course)).to be_a(Course)
expect(assigns(:course)).to be_persisted
end

it "redirects to the created course" do
post :create, {course: valid_attributes}, valid_session
post :create, params: {course: valid_attributes}, session: valid_session
expect(response).to redirect_to(courses_path)
end
end

context "with invalid params" do
it "assigns a newly created but unsaved course as @course" do
post :create, {course: invalid_attributes}, valid_session
post :create, params: {course: invalid_attributes}, session: valid_session
expect(assigns(:course)).to be_a_new(Course)
end

it "re-renders the 'new' template" do
post :create, {course: invalid_attributes}, valid_session
post :create, params: {course: invalid_attributes}, session: valid_session
expect(response).to render_template("new")
end
end
Expand All @@ -85,34 +85,34 @@

it "updates the requested course" do
course = Course.create! valid_attributes
put :update, {id: course.to_param, course: new_attributes}, valid_session
put :update, params: {id: course.to_param, course: new_attributes}, session: valid_session
course.reload
expect(course.name).to eq('RAILS5')
end

it "assigns the requested course as @course" do
course = Course.create! valid_attributes
put :update, {id: course.to_param, course: valid_attributes}, valid_session
put :update, params: {id: course.to_param, course: valid_attributes}, session: valid_session
expect(assigns(:course)).to eq(course)
end

it "redirects to the course" do
course = Course.create! valid_attributes
put :update, {id: course.to_param, course: valid_attributes}, valid_session
put :update, params: {id: course.to_param, course: valid_attributes}, session: valid_session
expect(response).to redirect_to(courses_path)
end
end

context "with invalid params" do
it "assigns the course as @course" do
course = Course.create! valid_attributes
put :update, {id: course.to_param, course: invalid_attributes}, valid_session
put :update, params: {id: course.to_param, course: invalid_attributes}, session: valid_session
expect(assigns(:course)).to eq(course)
end

it "re-renders the 'edit' template" do
course = Course.create! valid_attributes
put :update, {id: course.to_param, course: invalid_attributes}, valid_session
put :update, params: {id: course.to_param, course: invalid_attributes}, session: valid_session
expect(response).to render_template("edit")
end
end
Expand All @@ -122,13 +122,13 @@
it "destroys the requested course" do
course = Course.create! valid_attributes
expect {
delete :destroy, {id: course.to_param}, valid_session
delete :destroy, params: {id: course.to_param}, session: valid_session
}.to change(Course, :count).by(-1)
end

it "redirects to the courses list" do
course = Course.create! valid_attributes
delete :destroy, {id: course.to_param}, valid_session
delete :destroy, params: {id: course.to_param}, session: valid_session
expect(response).to redirect_to(courses_path)
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/controllers/event_sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
describe 'an unauthorized user' do
it 'cannot see a list of attendees' do
expect(
get :index, event_id: @event.id
get :index, params: { event_id: @event.id }
).to be_redirect
end
end
Expand All @@ -25,7 +25,7 @@

it 'can see a list of attendees' do
expect(
get :index, event_id: @event.id
get :index, params: { event_id: @event.id }
).not_to be_redirect
end
end
Expand All @@ -41,21 +41,21 @@

context 'format is ics' do
it 'responds with success' do
get :show, format: 'ics', event_id: @event.id, id: @event_session.id
get :show, params: { event_id: @event.id, id: @event_session.id }, format: 'ics'
expect(response).to be_success
end

it 'delegates to IcsGenerator' do
generator = double(event_session_ics: 'CALENDAR STUFF')
expect(IcsGenerator).to receive(:new).and_return(generator)

get :show, format: 'ics', event_id: @event.id, id: @event_session.id
get :show, params: { event_id: @event.id, id: @event_session.id }, format: 'ics'
end
end

context 'format is not ics' do
it 'responds with not_found' do
get :show, event_id: @event.id, id: @event_session.id
get :show, params: { event_id: @event.id, id: @event_session.id }
expect(response).to be_not_found
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/controllers/events/attendees_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

describe '#index' do
it 'responds to csv' do
get :index, event_id: @event.id, format: :csv
get :index, params: { event_id: @event.id }, format: :csv
expect(response).to have_http_status(:success)
expect(response.content_type).to eq('text/csv')

Expand All @@ -26,13 +26,13 @@
end

it 'includes organizers in csv' do
get :index, event_id: @event.id, format: :csv
get :index, params: { event_id: @event.id }, format: :csv
csv_rows = CSV.parse(response.body, headers: true)
expect(csv_rows[0]["Attending As"]).to eq('Organizer')
end

it 'includes all dietary info in the dietary info field' do
get :index, event_id: @event.id, format: :csv
get :index, params: { event_id: @event.id }, format: :csv
csv_rows = CSV.parse(response.body, headers: true)
expect(csv_rows[1]['Dietary Info']).to eq('Vegan, paleo')
end
Expand All @@ -41,7 +41,7 @@
another_user = create(:user, first_name: 'Xylophone', last_name: 'Xyson')
create(:rsvp, event: @event, user: another_user)

get :index, event_id: @event.id, format: :csv
get :index, params: { event_id: @event.id }, format: :csv
csv_rows = CSV.parse(response.body, headers: true)
expected = [
'Apple Pearson',
Expand All @@ -56,10 +56,10 @@
let!(:section) { create(:section, event: @event) }

let(:do_request) do
put :update, event_id: @event.id, id: @rsvp.id, attendee: {
put :update, params: { event_id: @event.id, id: @rsvp.id, attendee: {
section_id: section.id,
subject_experience: 'Some awesome string'
}
} }
end

it 'allows organizers to update an attendee\'s section_id' do
Expand Down
Loading

0 comments on commit 542dc15

Please sign in to comment.