require 'spec_helper' module Qcourses describe Registration do describe "saving" do let(:employee) { Rubory.create :employee } let(:event) { Rubory.create :event } let(:subject) {Registration.new(employee: employee, event: event)} it "can be saved and read back" do subject.save reloaded = Registration[subject.id] reloaded.should == subject end it "adds the registration to the event" do subject.save event.registrations.should include(subject) end it { should reject_values(nil).for(:employee) } it { should reject_values(nil).for(:event) } end end describe Employee do describe "saving" do let(:subject) { Rubory.build :employee } it "can be saved and read back" do subject.save reloaded = Employee[subject.id] reloaded.should == subject end it { should reject_values(nil, "").for(:name) } it { should reject_values( nil, "", "rob@", "@mo.nl", "123.nl", "123@nl", "aaa.123.nl", "aaa.123@nl").for(:email) } end end describe Company do describe "saving" do let(:subject) { Rubory.build :company } it "can be saved and read back" do subject.save reloaded = Company[subject.id] reloaded.should == subject end it { should reject_values(nil, "").for(:name) } it { should reject_values(nil, "").for(:contact_person) } it { should reject_values(nil, "").for(:invoice_address) } it { should reject_values(nil, "").for(:postal_code) } it { should reject_values(nil, "").for(:city) } it { should reject_values( nil, "", "rob@", "@mo.nl", "123.nl", "123@nl", "aaa.123.nl", "aaa.123@nl") .for(:contact_email) } end end end