From 80edc4f6139d1b94e4f941ee7cce9031353d932d Mon Sep 17 00:00:00 2001 From: Julian Herrero Date: Wed, 2 Mar 2016 16:01:34 +0100 Subject: [PATCH] add feature test for debates friendly urls --- spec/features/debates_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index 6ef03d06e..1e8f175e2 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -61,6 +61,28 @@ feature 'Debates' do expect(link_text).to include(debates_path order: :hot_score, page: 1) end + context "Show" do + scenario 'When path matches the friendly url' do + debate = create(:debate) + + right_path = debate_path(debate) + visit right_path + + expect(current_path).to eq(right_path) + end + + scenario 'When path does not match the friendly url' do + debate = create(:debate) + + right_path = debate_path(debate) + old_path = "#{debates_path}/#{debate.id}-something-else" + visit old_path + + expect(current_path).to_not eq(old_path) + expect(current_path).to eq(right_path) + end + end + scenario 'Create' do author = create(:user) login_as(author)