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 9ce47c8 commit 968c117
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions spec/controllers/entities/opportunities_controller_spec.rb
Expand Up @@ -56,7 +56,7 @@ def get_data_for_sidebar
@first = FactoryGirl.create(:opportunity, user: current_user, name: "The first one")
@second = FactoryGirl.create(:opportunity, user: current_user, name: "The second one")

get :index, query: "second"
get :index, params: { query: "second" }
expect(assigns[:opportunities]).to eq([@second])
expect(assigns[:current_query]).to eq("second")
expect(session[:opportunities_current_query]).to eq("second")
Expand Down Expand Up @@ -141,15 +141,15 @@ def get_data_for_sidebar
end

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

it "should update an activity when viewing the opportunity" do
get :show, id: @opportunity.id
get :show, params: { id: @opportunity.id }
expect(@opportunity.versions.last.event).to eq('view')
end
end
Expand All @@ -161,7 +161,7 @@ def get_data_for_sidebar
expect(@opportunity).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 @@ -173,7 +173,7 @@ def get_data_for_sidebar
expect(@opportunity).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 @@ -183,15 +183,15 @@ def get_data_for_sidebar
@opportunity = FactoryGirl.create(:opportunity, user: current_user)
@opportunity.destroy

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

it "should redirect to opportunity index if the opportunity is protected" do
@private = FactoryGirl.create(:opportunity, 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(opportunities_path)
end
Expand All @@ -201,7 +201,7 @@ def get_data_for_sidebar
@opportunity.destroy
request.env["HTTP_ACCEPT"] = "application/json"

get :show, id: @opportunity.id
get :show, params: { id: @opportunity.id }
expect(response.code).to eq("404") # :not_found
end

Expand All @@ -210,7 +210,7 @@ def get_data_for_sidebar
@opportunity.destroy
request.env["HTTP_ACCEPT"] = "application/xml"

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

describe "HTML request" do
it "should redirect to Opportunities index when an opportunity gets deleted from its landing page" do
delete :destroy, id: @opportunity.id
delete :destroy, params: { id: @opportunity.id }
expect(flash[:notice]).not_to eq(nil)
expect(response).to redirect_to(opportunities_path)
end
Expand All @@ -782,15 +782,15 @@ def get_data_for_sidebar
@opportunity = FactoryGirl.create(:opportunity, user: current_user)
@opportunity.destroy

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

it "should redirect to opportunity index with the flash message if the opportunity is protected" do
@private = FactoryGirl.create(:opportunity, 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(opportunities_path)
end
Expand Down

0 comments on commit 968c117

Please sign in to comment.