Skip to content

Commit

Permalink
Move survey greeting editing to its own page
Browse files Browse the repository at this point in the history
  • Loading branch information
tjgrathwell committed Nov 21, 2015
1 parent ba34257 commit 7acb8c1
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 15 deletions.
14 changes: 14 additions & 0 deletions app/controllers/events/surveys_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Events::SurveysController < ApplicationController
before_action :authenticate_user!
before_action :validate_organizer!
before_action :find_event

def edit
end

private

def find_event
@event = Event.find(params[:event_id])
end
end
9 changes: 0 additions & 9 deletions app/views/events/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,6 @@
<%= f.input :student_details, label: 'Student Details', input_html: {rows: 4} %>
</div>

<h3>Survey Details</h3>

<div class="field">
<p>
Email body - Link to survey will be included at bottom
</p>
<%= f.input :survey_greeting, label: 'Greeting', input_html: {rows: 4} %>
</div>

<% unless @event.published? %>
<h2>Announcement Email</h2>

Expand Down
12 changes: 6 additions & 6 deletions app/views/events/organizer_tools/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@
tip: 'Click here to send a link to the follow up survey to all students and volunteers.',
confirm: 'Are you sure?'
} %>
<%= render partial: 'shared/organizer_action', locals: {
path: edit_event_survey_path(@event),
icon: 'fa fa-edit',
text: 'Edit Survey Header',
tip: 'Change the text that attendees will see when they edit the survey.'
} %>
</section>
<% end %>
</div>
</div>

<div class="row">
<div class="col-md-12">
<h2>Survey Greeting</h2>
<%= simple_format_with_html(@event.survey_greeting) %>
</div>
</div>

16 changes: 16 additions & 0 deletions app/views/events/surveys/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%= simple_form_for @event do |f| %>
<%= render 'shared/model_error_messages', model: @event %>

<h3>Survey Details</h3>

<div class="field">
<p>
Email body - Link to survey will be included at bottom
</p>
<%= f.input :survey_greeting, label: 'Greeting', input_html: {rows: 4} %>
</div>

<div class="actions">
<%= f.submit %>
</div>
<% end %>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
resources :organizer_tools, only: [:index], controller: "events/organizer_tools"
controller "events/organizer_tools" do
get "send_survey_email"
resource :survey, only: [:edit], controller: "events/surveys"
get "organize_sections"
get "diets"
get "rsvp_preview"
Expand Down
8 changes: 8 additions & 0 deletions spec/features/event_organizer_dashboard_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,12 @@

expect(rsvp_session1.reload).not_to be_checked_in
end

it "lets the organizer update the survey greeting" do
visit event_organizer_tools_path(@event)
click_link "Edit Survey Header"
fill_in 'Greeting', with: 'Here is a fun survey'
click_on 'Update'
expect(@event.reload.survey_greeting).to eq('Here is a fun survey')
end
end

0 comments on commit 7acb8c1

Please sign in to comment.