Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

AO3-4934 Extend kudos feature and rspec tests #3150

Open
wants to merge 6 commits into
from

Conversation

Projects
None yet
3 participants
Contributor

hatal175 commented Nov 8, 2017

Issue

https://otwarchive.atlassian.net/browse/AO3-4934

Purpose

Completed coverage for the kudos controller

Testing

No new features just tests. Run them :)

Credit

Tal Hayon

Please use he

app/controllers/kudos_controller.rb
@@ -23,7 +23,7 @@ def create
format.html do
flash[:comment_notice] = ts("Thank you for leaving kudos!")
- redirect_to request.referer and return
+ redirect_to request.referer || root_path and return
@houndci-bot

houndci-bot Nov 8, 2017

Use && instead of and.

@@ -48,7 +48,7 @@ def create
error_message = "You can't leave guest kudos on a restricted work."
end
flash[:comment_error] = ts(error_message)
- redirect_to request.referer and return
+ redirect_to request.referer || root_path and return
@houndci-bot

houndci-bot Nov 8, 2017

Use && instead of and.

features/support/paths.rb
@@ -116,6 +116,8 @@ def path_to(page_name)
user_works_path(user_id: $1)
when /^the "(.*)" work page/
work_path(Work.find_by(title: $1)).sub("http://www.example.com", "//")
+ when /^the "(.*)" work kudos page/
@houndci-bot

houndci-bot Nov 8, 2017

Indent when as deep as case.

@@ -0,0 +1,40 @@
+require 'spec_helper'
@houndci-bot

houndci-bot Nov 8, 2017

Missing magic comment # frozen_string_literal: true.

@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+describe KudosController do
@houndci-bot

houndci-bot Nov 8, 2017

Block has too many lines. [30/25]

+ include LoginMacros
+ include RedirectExpectationHelper
+
+ describe 'create' do
@houndci-bot

houndci-bot Nov 8, 2017

Block has too many lines. [26/25]

app/controllers/kudos_controller.rb
@@ -23,7 +23,7 @@ def create
format.html do
flash[:comment_notice] = ts("Thank you for leaving kudos!")
- redirect_to request.referer and return
+ redirect_to (request.referer || root_path) && return
@houndci-bot

houndci-bot Nov 8, 2017

(...) interpreted as grouped expression.

app/controllers/kudos_controller.rb
@@ -48,7 +48,7 @@ def create
error_message = "You can't leave guest kudos on a restricted work."
end
flash[:comment_error] = ts(error_message)
- redirect_to request.referer and return
+ redirect_to (request.referer || root_path) && return
@houndci-bot

houndci-bot Nov 8, 2017

(...) interpreted as grouped expression.

@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+require 'spec_helper'
@houndci-bot

houndci-bot Nov 8, 2017

Add an empty line after magic comments.

Contributor

hatal175 commented Nov 8, 2017

Please do not bother reviewing until I've fixed the tests.

hatal175 added some commits Nov 9, 2017

app/controllers/kudos_controller.rb
@@ -23,7 +23,7 @@ def create
format.html do
flash[:comment_notice] = ts("Thank you for leaving kudos!")
- redirect_to request.referer and return
+ redirect_to request.referer || root_path and return
@sarken

sarken Nov 12, 2017

Owner

I'm not sure root_path is a good fallback for kudos -- if we can't redirect someone back to the exact referrer (which could be something like a specific chapter of the work they're kudosing or the work's kudos), we should at least redirect them to work.

- redirect_to request.referer and return
+ redirect_to request.referer || redirect_path and return
@houndci-bot

houndci-bot Nov 15, 2017

Use && instead of and.

+
+require 'spec_helper'
+
+describe KudosController do
@houndci-bot

houndci-bot Nov 15, 2017

Block has too many lines. [63/25]

+ include LoginMacros
+ include RedirectExpectationHelper
+
+ describe 'create' do
@houndci-bot

houndci-bot Nov 15, 2017

Block has too many lines. [59/25]

+ include RedirectExpectationHelper
+
+ describe 'create' do
+ context "when a regular work is posted" do
@houndci-bot

houndci-bot Nov 15, 2017

Block has too many lines. [38/25]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment