Skip to content

Commit 4090834

Browse files
committed
Added controller test for redirecting protip to slugged url
1 parent d9b722e commit 4090834

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

spec/controllers/protips_controller_spec.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,19 @@ def valid_session
4949
# end
5050
# end
5151

52-
describe "GET show" do
53-
it "assigns the requested protip as @protip" do
52+
describe "GET show using public_id" do
53+
it "redirects to GET show using slug" do
5454
protip = Protip.create! valid_attributes
5555
get :show, {id: protip.to_param}, valid_session
56+
expect(response).to redirect_to protip_path(protip.slug)
57+
end
58+
end
59+
60+
describe "GET show using slug" do
61+
it "assigns the requested protip as @protip" do
62+
protip = Protip.create! valid_attributes
63+
protip.save
64+
get :show, {id: protip.friendly_id}, valid_session
5665
expect(assigns(:protip)).to eq(protip)
5766
end
5867
end

0 commit comments

Comments
 (0)