Skip to content

Commit

Permalink
Rails 5 style
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Jul 17, 2017
1 parent a6d8969 commit f5ade87
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions spec/controllers/entities/contacts_controller_spec.rb
Expand Up @@ -27,7 +27,7 @@
@billy_bones = FactoryGirl.create(:contact, user: current_user, first_name: "Billy", last_name: "Bones")
@captain_flint = FactoryGirl.create(:contact, user: current_user, first_name: "Captain", last_name: "Flint")

get :index, query: @billy_bones.email
get :index, params: { query: @billy_bones.email }
expect(assigns[:contacts]).to eq([@billy_bones])
expect(assigns[:current_query]).to eq(@billy_bones.email)
expect(session[:contacts_current_query]).to eq(@billy_bones.email)
Expand Down Expand Up @@ -101,15 +101,15 @@
end

it "should expose the requested contact as @contact" do
get :show, id: 42
get :show, params: { id: 42 }
expect(assigns[:contact]).to eq(@contact)
expect(assigns[:stage]).to eq(@stage)
expect(assigns[:comment].attributes).to eq(@comment.attributes)
expect(response).to render_template("contacts/show")
end

it "should update an activity when viewing the contact" do
get :show, id: @contact.id
get :show, params: { id: @contact.id }
expect(@contact.versions.last.event).to eq('view')
end
end
Expand All @@ -121,7 +121,7 @@
expect(@contact).to receive(:to_json).and_return("generated JSON")

request.env["HTTP_ACCEPT"] = "application/json"
get :show, id: 42
get :show, params: { id: 42 }
expect(response.body).to eq("generated JSON")
end
end
Expand All @@ -133,7 +133,7 @@
expect(@contact).to receive(:to_xml).and_return("generated XML")

request.env["HTTP_ACCEPT"] = "application/xml"
get :show, id: 42
get :show, params: { id: 42 }
expect(response.body).to eq("generated XML")
end
end
Expand All @@ -143,15 +143,15 @@
@contact = FactoryGirl.create(:contact, user: current_user)
@contact.destroy

get :show, id: @contact.id
get :show, params: { id: @contact.id }
expect(flash[:warning]).not_to eq(nil)
expect(response).to redirect_to(contacts_path)
end

it "should redirect to contact index if the contact is protected" do
@private = FactoryGirl.create(:contact, user: FactoryGirl.create(:user), access: "Private")

get :show, id: @private.id
get :show, params: { id: @private.id }
expect(flash[:warning]).not_to eq(nil)
expect(response).to redirect_to(contacts_path)
end
Expand All @@ -161,7 +161,7 @@
@contact.destroy
request.env["HTTP_ACCEPT"] = "application/xml"

get :show, id: @contact.id
get :show, params: { id: @contact.id }
expect(response.code).to eq("404") # :not_found
end
end
Expand Down Expand Up @@ -567,7 +567,7 @@

describe "HTML request" do
it "should redirect to Contacts index when a contact gets deleted from its landing page" do
delete :destroy, id: @contact.id
delete :destroy, params: { id: @contact.id }

expect(flash[:notice]).not_to eq(nil)
expect(response).to redirect_to(contacts_path)
Expand All @@ -577,15 +577,15 @@
@contact = FactoryGirl.create(:contact, user: current_user)
@contact.destroy

delete :destroy, id: @contact.id
delete :destroy, params: { id: @contact.id }
expect(flash[:warning]).not_to eq(nil)
expect(response).to redirect_to(contacts_path)
end

it "should redirect to contact index with the flash message if the contact is protected" do
@private = FactoryGirl.create(:contact, user: FactoryGirl.create(:user), access: "Private")

delete :destroy, id: @private.id
delete :destroy, params: { id: @private.id }
expect(flash[:warning]).not_to eq(nil)
expect(response).to redirect_to(contacts_path)
end
Expand Down

0 comments on commit f5ade87

Please sign in to comment.