More tests.

pull/6827/head
Felix Schäfer 14 years ago
parent 5d5addcf80
commit 05a9515a28
  1. 6
      app/models/meeting.rb
  2. 81
      spec/controllers/meetings_controller_spec.rb
  3. 21
      spec/models/meeting_spec.rb

@ -27,15 +27,15 @@ class Meeting < ActiveRecord::Base
def start_date def start_date
# the text_field + calendar_for form helpers expect a Date # the text_field + calendar_for form helpers expect a Date
start_time.to_date if start_time.present? start_time.to_date
end end
def start_month def start_month
start_time.month if start_time.present? start_time.month
end end
def start_year def start_year
start_time.year if start_time.present? start_time.year
end end
def end_time def end_time

@ -22,5 +22,86 @@ describe MeetingsController do
it {assigns(:meetings_by_start_year_month_date).should eql @ms} it {assigns(:meetings_by_start_year_month_date).should eql @ms}
end end
end end
describe "show" do
before(:each) do
@m = mock_model(Meeting)
Meeting.stub!(:find).and_return(@m)
@m.stub(:project).and_return(@p)
end
describe "html" do
before(:each) do
get "show"
end
it {response.should be_success}
end
end
describe "new without copy" do
before(:each) do
Project.stub!(:find).and_return(@p)
@m = mock_model(Meeting)
Meeting.stub!(:new).and_return(@m)
end
describe "html" do
before(:each) do
get "new"
end
it {response.should be_success}
it {assigns(:meeting).should eql @m}
end
end
describe "new with copy" do
before(:each) do
Project.stub!(:find).and_return(@p)
@m = mock_model(Meeting)
Meeting.stub!(:new).and_return(@m)
end
#describe "with a valid meeting ID" do
# before(:each) do
# @mc = mock_model(Meeting)
# Meeting.stub!(:find).and_return(@mc)
# @mc.stub!(:attributes).and_return({"duration"=>1.5, "location"=>"Raum 4", "title"=>"dingens", "updated_at"=>Time.parse("Thu Feb 17 11:33:22 +0100 2011")})
# @mc.stub!(:start_time).and_return(Time.parse("Fri Feb 18 14:36:25 +0100 2011"))
# @mc.stub!(:participants).and_return([mock_model(MeetingParticipant), mock_model(MeetingParticipant), mock_model(MeetingParticipant)])
# end
# describe "html" do
# before(:each) do
# get "new", :copy_from_id => 1
# end
# it {pending; response.should be_success}
# it {pending; assigns(:meeting).should eql @m}
# it {pending} # TODO: testen ob das richtig kopiert wird
# end
#end
describe "with an invalid meeting ID" do
before(:each) do
Meeting.stub!(:find).and_raise(ActiveRecord::RecordNotFound)
end
describe "html" do
before(:each) do
get "new", :copy_from_id => 1
end
it {response.should be_success}
it {assigns(:meeting).should eql @m}
end
end
end
describe "edit" do
before(:each) do
@m = mock_model(Meeting)
Meeting.stub!(:find).and_return(@m)
@m.stub(:project).and_return(@p)
end
describe "html" do
before(:each) do
get "edit"
end
it {response.should be_success}
it {assigns(:meeting).should eql @m}
end
end
end end
end end

@ -2,15 +2,36 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Meeting do describe Meeting do
it {should belong_to :project} it {should belong_to :project}
it {should belong_to :author}
it {should validate_presence_of :title} it {should validate_presence_of :title}
it {should validate_presence_of :start_time}
it {pending; should accept_nested_attributes_for :participants} # geht das?
before(:all) do before(:all) do
@m = Factory.build :meeting, :title => "dingens" @m = Factory.build :meeting, :title => "dingens"
end end
describe "to_s" do describe "to_s" do
it {@m.to_s.should == "dingens"} it {@m.to_s.should == "dingens"}
end end
describe "start_date" do describe "start_date" do
it {@m.start_date.should == Date.tomorrow} it {@m.start_date.should == Date.tomorrow}
end end
describe "start_month" do
it {@m.start_month.should == Date.tomorrow.month}
end
describe "start_year" do
it {@m.start_year.should == Date.tomorrow.year}
end
describe "end_time" do
it {@m.end_time.should == Date.tomorrow + 11.hours}
end
describe "time-sorted finder" do
it {pending}
end
end end
Loading…
Cancel
Save