Skip to content

Commit

Permalink
Merge branch 'master' into with_ruby192
Browse files Browse the repository at this point in the history
* master:
  Fix Event#to_clone to also include :venue_details. Rewrite spec in RSpec 2 format .
  • Loading branch information
igal committed Oct 27, 2011
2 parents 0f0fda2 + 5897564 commit 762138f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def normalize_url!
end

# Array of attributes that should be cloned by #to_clone.
CLONE_ATTRIBUTES = [:title, :description, :venue_id, :url, :tag_list]
CLONE_ATTRIBUTES = [:title, :description, :venue_id, :url, :tag_list, :venue_details]

# Return a new record with fields selectively copied from the original, and
# the start_time and end_time adjusted so that their date is set to today and
Expand Down
40 changes: 18 additions & 22 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -761,34 +761,30 @@ def find_duplicates_create_a_clone_and_find_again(find_duplicates_arguments, clo
end

describe "when cloning" do
fixtures :all

before(:each) do
@original = events(:calagator_codesprint)
@original.start_time = Time.parse("2008-01-19 10:00 PST")
@original.end_time = Time.parse("2008-01-19 17:00 PST")
@clone = @original.to_clone
let :original do
Factory(:event,
:start_time => Time.parse("2008-01-19 10:00 PST"),
:end_time => Time.parse("2008-01-19 17:00 PST"),
:tag_list => "foo, bar, baz",
:venue_details => "Details")
end

it "should be a new record" do
@clone.should be_a_new_record
subject do
original.to_clone
end

it "should not have an id" do
@clone.id.should be_nil
end
its(:new_record?) { should be_true }

it "should set start and end time to original time of day for today" do
@clone.start_time.should == Time.today + 10.hours
@clone.end_time.should == Time.today + 17.hours
end
its(:id) { should be_nil }

its(:start_time) { should == Time.today + original.start_time.hour.hours }

its(:end_time) { should == Time.today + original.end_time.hour.hours }

its(:tag_list) { should == original.tag_list }

it "should duplicate title, description, venue, url and tag_list" do
@clone.title.should == @original.title
@clone.description.should == @original.description
@clone.url.should == @original.url
@clone.venue.should == @original.venue
@clone.tag_list.should == @original.tag_list
%w[title description url venue_id venue_details].each do |field|
its(field) { should == original[field] }
end
end

Expand Down

0 comments on commit 762138f

Please sign in to comment.