Adds User.is_organization and User.organization_name

This commit is contained in:
kikito
2015-08-14 20:24:19 +02:00
parent 4e5d53f2f1
commit 60a1cc2267
2 changed files with 38 additions and 10 deletions

View File

@@ -123,16 +123,34 @@ describe User do
expect(subject.organization?).to be true
end
it "deactivates the validation of first_name and last_name" do
subject.first_name = nil
subject.last_name = nil
expect(subject).to be_valid
end
it "calculates the name using the organization name" do
expect(subject.name).to eq(subject.organization.name)
end
end
end
describe "is_organization" do
before(:each) { subject.is_organization = true }
it "deactivates the validation of first_name and last_name, and activates the validation of organization_name" do
subject.first_name = nil
subject.last_name = nil
subject.organization_name = nil
expect(subject).to_not be_valid
subject.organization_name = 'org'
expect(subject).to be_valid
end
it "triggers the creation of an associated organization using organization_name" do
expect(subject.organization).to_not be
subject.is_organization = true
subject.organization_name = 'org'
subject.save
expect(subject.organization).to be
end
end
end