-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add a dedicated recommended talks using turbo frame * restrict this route to turbo frame requests only * remove @talks form talk#show * add a basic test * try to remove flaky
- Loading branch information
1 parent
38a7b1b
commit f3b0f80
Showing
11 changed files
with
60 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Talks::RecommendationsController < ApplicationController | ||
skip_before_action :authenticate_user! | ||
before_action :set_talk, only: %i[index] | ||
|
||
def index | ||
redirect_to talk_path(@talk) unless turbo_frame_request? | ||
@talks = @talk.related_talks | ||
end | ||
|
||
private | ||
|
||
def set_talk | ||
@talk = Talk.find_by(slug: params[:talk_slug]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= turbo_frame_tag "recommended_talks" do %> | ||
<div data-turbo-temporary data-controller="transition" class="hidden" data-transition-enter-after-value="0"> | ||
<%= render partial: "talks/card_horizontal", collection: @talks, as: :talk, locals: {compact: true} %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require "test_helper" | ||
|
||
class Talks::RecommendationsControllerTest < ActionDispatch::IntegrationTest | ||
def setup | ||
@talk = talks(:one) | ||
end | ||
|
||
test "should get index with a turbo stream request" do | ||
get talk_recommendations_url(@talk), headers: {"Turbo-Frame" => "true"} | ||
assert_response :success | ||
assert_equal assigns(:talk).id, @talk.id | ||
assert_not_nil assigns(:talks) | ||
end | ||
|
||
test "a none turbo stream request should redirect to the talk" do | ||
get talk_recommendations_url(@talk) | ||
assert_redirected_to talk_url(@talk) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters