Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,13 @@ def review_all
def approve
authorize @comment
@comment.mark_as_ham!
redirect_to_all_comments(@comment.ultimate_parent, show_comments: true)
redirect_to_all_comments(@comment.parent, show_comments: true)
end

def reject
authorize @comment if logged_in_as_admin?
@comment.mark_as_spam!
redirect_to_all_comments(@comment.ultimate_parent, show_comments: true)
redirect_to_all_comments(@comment.parent, show_comments: true)
end

# PUT /comments/1/freeze
Expand All @@ -547,10 +547,10 @@ def freeze
flash[:comment_notice] = t(".success")
end

redirect_to_all_comments(@comment.ultimate_parent, show_comments: true)
redirect_to_all_comments(@comment.parent, show_comments: true)
rescue StandardError
flash[:comment_error] = t(".error")
redirect_to_all_comments(@comment.ultimate_parent, show_comments: true)
redirect_to_all_comments(@comment.parent, show_comments: true)
end

# PUT /comments/1/unfreeze
Expand All @@ -565,10 +565,10 @@ def unfreeze
flash[:comment_error] = t(".error")
end

redirect_to_all_comments(@comment.ultimate_parent, show_comments: true)
redirect_to_all_comments(@comment.parent, show_comments: true)
rescue StandardError
flash[:comment_error] = t(".error")
redirect_to_all_comments(@comment.ultimate_parent, show_comments: true)
redirect_to_all_comments(@comment.parent, show_comments: true)
end

# PUT /comments/1/hide
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/comments/comment_moderation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@
it "marks the comment as spam" do
put :reject, params: { id: comment.id }
expect(flash[:error]).to be_nil
expect(response).to redirect_to(work_path(comment.ultimate_parent,
expect(response).to redirect_to(chapter_path(comment.parent,
show_comments: true,
anchor: "comments"))
comment.reload
Expand Down Expand Up @@ -366,7 +366,7 @@
it "marks the comment as spam" do
put :reject, params: { id: comment.id }
expect(flash[:error]).to be_nil
expect(response).to redirect_to(work_path(comment.ultimate_parent,
expect(response).to redirect_to(chapter_path(comment.parent,
show_comments: true,
anchor: "comments"))
comment.reload
Expand Down Expand Up @@ -479,7 +479,7 @@
it "marks the comment as not spam" do
put :approve, params: { id: comment.id }
expect(flash[:error]).to be_nil
expect(response).to redirect_to(work_path(comment.ultimate_parent,
expect(response).to redirect_to(chapter_path(comment.parent,
show_comments: true,
anchor: "comments"))
comment.reload
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/comments/comments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
it "PUT #freeze successfully freezes the comment" do
put :freeze, params: { id: comment.id }
it_redirects_to_with_comment_notice(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Comment thread successfully frozen!"
)
expect(comment.reload.iced).to be_truthy
Expand All @@ -355,7 +355,7 @@
comment.update!(iced: true)
put :unfreeze, params: { id: comment.id }
it_redirects_to_with_comment_notice(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Comment thread successfully unfrozen!"
)
expect(comment.reload.iced).to be_falsey
Expand Down Expand Up @@ -442,7 +442,7 @@
fake_login_admin(admin)
put :freeze, params: { id: comment.id }
it_redirects_to_with_comment_notice(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Comment thread successfully frozen!"
)
expect(comment.reload.iced).to be_truthy
Expand All @@ -466,7 +466,7 @@
fake_login_admin(admin)
put :unfreeze, params: { id: comment.id }
it_redirects_to_with_comment_notice(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Comment thread successfully unfrozen!"
)
expect(comment.reload.iced).to be_falsey
Expand Down
32 changes: 16 additions & 16 deletions spec/controllers/comments/freeze_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@

expect(comment.reload.iced).to be true
it_redirects_to_with_comment_notice(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Comment thread successfully frozen!"
)
end
Expand Down Expand Up @@ -300,7 +300,7 @@

expect(comment.reload.iced).to be false
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be frozen."
)
end
Expand Down Expand Up @@ -449,7 +449,7 @@

expect(comment.reload.iced).to be_truthy
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be frozen."
)
end
Expand All @@ -474,7 +474,7 @@

expect(comment.reload.iced).to be_truthy
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be frozen."
)
end
Expand All @@ -495,7 +495,7 @@
expect(comment.reload.iced).to be_truthy
end
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be frozen."
)
end
Expand All @@ -515,7 +515,7 @@
expect(comment.reload.iced).to be_truthy
end
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be frozen."
)
end
Expand All @@ -535,7 +535,7 @@
expect(comment.reload.iced).to be_truthy
end
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be frozen."
)
end
Expand All @@ -554,7 +554,7 @@

expect(comment.reload.iced).to be true
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be frozen."
)
end
Expand Down Expand Up @@ -703,7 +703,7 @@

expect(comment.reload.iced).to be_falsey
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be unfrozen."
)
end
Expand All @@ -728,7 +728,7 @@

expect(comment.reload.iced).to be_falsey
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be unfrozen."
)
end
Expand All @@ -749,7 +749,7 @@
expect(comment.reload.iced).to be_falsey
end
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be unfrozen."
)
end
Expand All @@ -769,7 +769,7 @@
expect(comment.reload.iced).to be_falsey
end
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be unfrozen."
)
end
Expand All @@ -789,7 +789,7 @@
expect(comment.reload.iced).to be_falsey
end
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be unfrozen."
)
end
Expand All @@ -808,7 +808,7 @@

expect(comment.reload.iced).to be false
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be unfrozen."
)
end
Expand Down Expand Up @@ -929,7 +929,7 @@

expect(comment.reload.iced).to be false
it_redirects_to_with_comment_notice(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Comment thread successfully unfrozen!"
)
end
Expand Down Expand Up @@ -1065,7 +1065,7 @@

expect(comment.reload.iced).to be true
it_redirects_to_with_comment_error(
work_path(comment.ultimate_parent, show_comments: true, anchor: :comments),
chapter_path(comment.parent, show_comments: true, anchor: :comments),
"Sorry, that comment thread could not be unfrozen."
)
end
Expand Down
Loading