From 9868dafd2a2ff2a9db97db35722fafa96a4c38cd Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 7 Mar 2013 20:06:59 -0800 Subject: [PATCH] new event form: 'General Event Details' and pre-filled content [fixes #45628333] --- app/models/event.rb | 22 ++++++++++++++++++++++ app/views/events/_form.html.erb | 2 +- spec/models/event_spec.rb | 6 ++++++ spec/requests/new_event_request_spec.rb | 19 +++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 spec/requests/new_event_request_spec.rb diff --git a/app/models/event.rb b/app/models/event.rb index e49875b01..e1cd0ccce 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -1,4 +1,6 @@ class Event < ActiveRecord::Base + after_initialize :set_defaults + belongs_to :location has_many :rsvps, dependent: :destroy @@ -50,4 +52,24 @@ def volunteer?(user) def organizer?(user) organizer_rsvps.where(user_id: user.id).any? end + + private + + def set_defaults + self.details ||= Event::DEFAULT_DETAILS + end + + DEFAULT_DETAILS = <<-END +

Workshop Description

+ +

Location and Sponsors

+ +

Transportation and Parking

+ +

Food and Drinks

+ +

Childcare

+ +

Afterparty

+ END end diff --git a/app/views/events/_form.html.erb b/app/views/events/_form.html.erb index 28baa74f9..08a481fe8 100644 --- a/app/views/events/_form.html.erb +++ b/app/views/events/_form.html.erb @@ -40,7 +40,7 @@
- <%= f.label :details, 'Details (some html allowed)' %> + <%= f.label :details, 'General Event Details (some html allowed)' %> <%= f.text_area :details, :rows => 4, :class => "input-xxlarge"%>
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index a4cbb15f3..8097bbf5a 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -77,4 +77,10 @@ Event.upcoming.should_not include(@event_past) end end + + describe "#details" do + it "has default content" do + Event.new.details.should =~ /Workshop Description/ + end + end end diff --git a/spec/requests/new_event_request_spec.rb b/spec/requests/new_event_request_spec.rb new file mode 100644 index 000000000..907e0cead --- /dev/null +++ b/spec/requests/new_event_request_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe "New Event" do + before do + @user_organizer = create(:user, email: "orgainzer@mail.com", first_name: "Sam", last_name: "Spade") + + sign_in_as(@user_organizer) + + visit "/events/new" + end + + + + it "should pre-fill the event details textarea" do + page.should have_field('General Event Details') + page.field_labeled('General Event Details')[:value].should =~ /Workshop Description/ + end + +end