Move 'Show stats and results' form to Admin::Poll#results tab
This commit is contained in:
@@ -55,17 +55,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if controller_name == "polls" && action_name == "edit" %>
|
||||
<div class="row">
|
||||
<fieldset class="fieldset">
|
||||
<legend><%= t('admin.polls.new.show_results_and_stats') %></legend>
|
||||
<%= f.check_box :results_enabled, checked: @poll.results_enabled?, label: t('admin.polls.new.show_results') %>
|
||||
<%= f.check_box :stats_enabled, checked: @poll.stats_enabled?, label: t('admin.polls.new.show_stats') %>
|
||||
<p class="small"><%= t('admin.polls.new.results_and_stats_reminder') %></p>
|
||||
</fieldset>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"),
|
||||
|
||||
17
app/views/admin/poll/results/_show_results.html.erb
Normal file
17
app/views/admin/poll/results/_show_results.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<%= form_for [:admin, @poll], action: "update" do |f| %>
|
||||
<div class="row">
|
||||
<fieldset class="fieldset">
|
||||
<legend><%= t("admin.polls.new.show_results_and_stats") %></legend>
|
||||
<%= f.check_box :results_enabled, checked: @poll.results_enabled?, label: t("admin.polls.new.show_results") %>
|
||||
<%= f.check_box :stats_enabled, checked: @poll.stats_enabled?, label: t("admin.polls.new.show_stats") %>
|
||||
<p class="small"><%= t("admin.polls.new.results_and_stats_reminder") %></p>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"),
|
||||
class: "button success expanded" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,4 +1,5 @@
|
||||
<%= render "/admin/poll/polls/poll_header" %>
|
||||
|
||||
<div id="poll-resources">
|
||||
<%= render "/admin/poll/polls/subnav" %>
|
||||
|
||||
@@ -12,5 +13,6 @@
|
||||
<%= render "recount", resource: @poll %>
|
||||
<%= render "result" %>
|
||||
<%= render "results_by_booth" %>
|
||||
<%= render "show_results", resource: @poll %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -83,25 +83,67 @@ feature 'Admin polls' do
|
||||
|
||||
expect(page).to have_css("img[alt='#{poll.image.title}']")
|
||||
|
||||
expect(page).to have_css("#poll_results_enabled")
|
||||
expect(page).to have_css("#poll_stats_enabled")
|
||||
|
||||
fill_in "poll_name", with: "Next Poll"
|
||||
fill_in 'poll_ends_at', with: end_date.strftime("%d/%m/%Y")
|
||||
check 'poll_results_enabled'
|
||||
check 'poll_stats_enabled'
|
||||
|
||||
click_button "Update poll"
|
||||
|
||||
expect(page).to have_content "Poll updated successfully"
|
||||
expect(page).to have_content "Next Poll"
|
||||
expect(page).to have_content I18n.l(end_date.to_date)
|
||||
end
|
||||
|
||||
click_link "Edit poll"
|
||||
scenario 'Enable stats and results' do
|
||||
poll = create(:poll)
|
||||
|
||||
booth_assignment_1 = create(:poll_booth_assignment, poll: poll)
|
||||
booth_assignment_2 = create(:poll_booth_assignment, poll: poll)
|
||||
booth_assignment_3 = create(:poll_booth_assignment, poll: poll)
|
||||
|
||||
question_1 = create(:poll_question, poll: poll)
|
||||
create(:poll_question_answer, title: 'Oui', question: question_1)
|
||||
create(:poll_question_answer, title: 'Non', question: question_1)
|
||||
|
||||
question_2 = create(:poll_question, poll: poll)
|
||||
create(:poll_question_answer, title: "Aujourd'hui", question: question_2)
|
||||
create(:poll_question_answer, title: 'Demain', question: question_2)
|
||||
|
||||
[booth_assignment_1, booth_assignment_2, booth_assignment_3].each do |ba|
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: ba,
|
||||
question: question_1,
|
||||
answer: 'Oui',
|
||||
amount: 11)
|
||||
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: ba,
|
||||
question: question_2,
|
||||
answer: 'Demain',
|
||||
amount: 5)
|
||||
end
|
||||
|
||||
create(:poll_recount,
|
||||
booth_assignment: booth_assignment_1,
|
||||
white_amount: 21,
|
||||
null_amount: 44,
|
||||
total_amount: 66)
|
||||
|
||||
visit admin_poll_results_path(poll)
|
||||
|
||||
expect(page).to have_field('poll_stats_enabled', checked: false)
|
||||
expect(page).to have_field('poll_results_enabled', checked: false)
|
||||
|
||||
check 'poll_stats_enabled'
|
||||
check 'poll_results_enabled'
|
||||
|
||||
click_button 'Update poll'
|
||||
|
||||
expect(page).to have_content('Poll updated successfully')
|
||||
|
||||
click_link 'Results'
|
||||
|
||||
expect(page).to have_field('poll_results_enabled', checked: true)
|
||||
expect(page).to have_field('poll_stats_enabled', checked: true)
|
||||
|
||||
expect(page).to have_field('poll_results_enabled', checked: true)
|
||||
end
|
||||
|
||||
scenario 'Edit from index' do
|
||||
|
||||
Reference in New Issue
Block a user