Skip to content

Commit

Permalink
Merge 717845f into d27bfb2
Browse files Browse the repository at this point in the history
  • Loading branch information
decabeza committed Jan 12, 2023
2 parents d27bfb2 + 717845f commit 79cd7b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions app/helpers/polls_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ def booth_name_with_location(booth)
booth.name + location
end

def link_to_poll(text, poll)
def link_to_poll(text, poll, options = {})
if can?(:results, poll)
link_to text, results_poll_path(id: poll.slug || poll.id)
link_to text, results_poll_path(id: poll.slug || poll.id), options
elsif can?(:stats, poll)
link_to text, stats_poll_path(id: poll.slug || poll.id)
link_to text, stats_poll_path(id: poll.slug || poll.id), options
else
link_to text, poll_path(id: poll.slug || poll.id)
link_to text, poll_path(id: poll.slug || poll.id), options
end
end

Expand Down
10 changes: 4 additions & 6 deletions app/views/polls/_poll_group.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@
</div>
<div class="small-12 medium-3 column table" data-equalizer-watch>
<div class="table-cell align-middle">
<%= link_to poll_path(id: poll.slug || poll.id), class: "button hollow expanded" do %>
<% if poll.expired? %>
<%= t("polls.index.participate_button_expired") %>
<% else %>
<%= t("polls.index.participate_button") %>
<% end %>
<% if poll.expired? %>
<%= link_to_poll t("polls.index.participate_button_expired"), poll, class: "button hollow expanded" %>
<% else %>
<%= link_to_poll t("polls.index.participate_button"), poll, class: "button hollow expanded" %>
<% end %>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions spec/system/polls/polls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,22 @@
expect(page).to have_content("You already have participated in this poll")
end

scenario "Poll title link to stats if enabled" do
scenario "Poll title and button link to stats if enabled" do
poll = create(:poll, :expired, name: "Poll with stats", stats_enabled: true)

visit polls_path(filter: "expired")

expect(page).to have_link("Poll with stats", href: stats_poll_path(poll.slug))
expect(page).to have_link("Poll ended", href: stats_poll_path(poll.slug))
end

scenario "Poll title link to results if enabled" do
scenario "Poll title and button link to results if enabled" do
poll = create(:poll, :expired, name: "Poll with results", stats_enabled: true, results_enabled: true)

visit polls_path(filter: "expired")

expect(page).to have_link("Poll with results", href: results_poll_path(poll.slug))
expect(page).to have_link("Poll ended", href: results_poll_path(poll.slug))
end

scenario "Shows SDG tags when feature is enabled" do
Expand Down

0 comments on commit 79cd7b0

Please sign in to comment.