Adds user.verified_organization?

This commit is contained in:
kikito
2015-08-18 17:24:31 +02:00
committed by Juanjo Bazán
parent 04db8112b4
commit 21c2fa2e3d
2 changed files with 23 additions and 0 deletions

View File

@@ -47,6 +47,10 @@ class User < ActiveRecord::Base
organization.present? organization.present?
end end
def verified_organization?
organization && organization.verified?
end
def official? def official?
official_level && official_level > 0 official_level && official_level > 0
end end

View File

@@ -125,6 +125,25 @@ describe User do
end end
end end
describe "verified_organization?" do
it "is falsy when the user is not an organization" do
expect(subject).to_not be_verified_organization
end
describe 'when it is an organization' do
before(:each) { create(:organization, user: subject) }
it "is false when the user is not a verified organization" do
expect(subject).to_not be_verified_organization
end
it "is true when the user is a verified organization" do
subject.organization.verify
expect(subject).to be_verified_organization
end
end
end
describe "organization_attributes" do describe "organization_attributes" do
before(:each) { subject.organization_attributes = {name: 'org'} } before(:each) { subject.organization_attributes = {name: 'org'} }