Skip to content

Commit

Permalink
Open diagram for smart answer in new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Ana Botto committed Dec 18, 2023
1 parent 660293b commit 9154f95
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions app/views/editions/diagram.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<%= render 'shared/edition_header' %>

<p>
<%= link_to "Back to current edition", edition_path(@resource.history.first), :class => "btn btn-default" %>
</p>

<div class="smart-answer-flowchart" data-module="smart-answer-flowchart">
<pre class="mermaid flowchart flowchart--hidden">
<%= @resource.generate_mermaid %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/editions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="link-check-report col-md-4">
<% if @edition.class.to_s == "SimpleSmartAnswerEdition" %>
<p>
View the <%= link_to "flow diagram", diagram_edition_path(@edition) %>
View the <%= link_to "flow diagram (opens in a new tab)", diagram_edition_path(@edition), target: '_blank' %>
</p>
<% end %>

Expand Down
6 changes: 3 additions & 3 deletions test/functional/editions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1048,15 +1048,15 @@ class EditionsControllerTest < ActionController::TestCase

get :show, params: { id: simple_smart_answer.id }

assert_select ".link-check-report p", { text: "View the flow diagram" } do
assert_select ".link-check-report p", { text: "View the flow diagram (opens in a new tab)" } do
assert_select "a[href=?]", diagram_edition_path(simple_smart_answer).to_s,
{ count: 1, text: "flow diagram" }
{ count: 1, text: "flow diagram (opens in a new tab)" }
end
end

should "not render a link to the diagram when edition is not a simple smart answer" do
get :show, params: { id: @guide.id }
assert_select "p", { count: 0, text: "View the flow diagram" }
assert_select "p", { count: 0, text: "View the flow diagram (opens in a new tab)" }
end
end

Expand Down

0 comments on commit 9154f95

Please sign in to comment.