diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 12d0b3e99..e09f1ccaa 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -45,9 +45,9 @@
- - - + <%= link_to request.referer.present? ? :back : commentable.path do %> + + <% end %> <%= f.submit "SUBMIT", id: "submit-button", onclick:"validateField(event)", class:"comment-action-button" %>
diff --git a/spec/features/user_delete_a_comment_spec.rb b/spec/features/comments/user_delete_a_comment_spec.rb similarity index 100% rename from spec/features/user_delete_a_comment_spec.rb rename to spec/features/comments/user_delete_a_comment_spec.rb diff --git a/spec/features/user_edits_a_comment_spec.rb b/spec/features/comments/user_edits_a_comment_spec.rb similarity index 72% rename from spec/features/user_edits_a_comment_spec.rb rename to spec/features/comments/user_edits_a_comment_spec.rb index 065e79a1d..6f318b5ff 100644 --- a/spec/features/user_edits_a_comment_spec.rb +++ b/spec/features/comments/user_edits_a_comment_spec.rb @@ -4,9 +4,9 @@ RSpec.describe "Editing A Comment", type: :feature, js: true do let(:user) { create(:user) } let!(:article) { create(:article, show_comments: true) } let(:new_comment_text) { Faker::Lorem.paragraph } + let!(:comment) { create(:comment, commentable: article, user: user, body_markdown: Faker::Lorem.paragraph) } before do - comment = create(:comment, commentable: article, user: user, body_markdown: Faker::Lorem.paragraph) Notification.send_new_comment_notifications(comment) sign_in user end @@ -34,4 +34,12 @@ RSpec.describe "Editing A Comment", type: :feature, js: true do assert_updated end end + + context "when user edits via direct path (no referer)" do + it "cancels to the article page" do + user.reload + visit "#{comment.path}/edit" + expect(page).to have_link("CANCEL", href: article.path.to_s) + end + end end diff --git a/spec/features/user_fills_out_comment_spec.rb b/spec/features/comments/user_fills_out_comment_spec.rb similarity index 100% rename from spec/features/user_fills_out_comment_spec.rb rename to spec/features/comments/user_fills_out_comment_spec.rb