Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Polyrhythm/bridge_troll i…
Browse files Browse the repository at this point in the history
…nto Polyrhythm-master
  • Loading branch information
tjgrathwell committed Mar 8, 2013
2 parents 04846ec + 9868daf commit a7ab769
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
22 changes: 22 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Event < ActiveRecord::Base
after_initialize :set_defaults

belongs_to :location

has_many :rsvps, dependent: :destroy
Expand Down Expand Up @@ -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
<h2>Workshop Description</h2>
<h2>Location and Sponsors</h2>
<h2>Transportation and Parking</h2>
<h2>Food and Drinks</h2>
<h2>Childcare</h2>
<h2>Afterparty</h2>
END
end
2 changes: 1 addition & 1 deletion app/views/events/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</div>

<div class="field">
<%= 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"%>
</div>

Expand Down
6 changes: 6 additions & 0 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions spec/requests/new_event_request_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a7ab769

Please sign in to comment.