From 21c2fa2e3d8969712a4c6050997aa58922c5fd93 Mon Sep 17 00:00:00 2001 From: kikito Date: Tue, 18 Aug 2015 17:24:31 +0200 Subject: [PATCH] Adds user.verified_organization? --- app/models/user.rb | 4 ++++ spec/models/user_spec.rb | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 0bb85937f..b6374f518 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -47,6 +47,10 @@ class User < ActiveRecord::Base organization.present? end + def verified_organization? + organization && organization.verified? + end + def official? official_level && official_level > 0 end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 4752e6f28..f64888236 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -125,6 +125,25 @@ describe User do 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 before(:each) { subject.organization_attributes = {name: 'org'} }