From 83e3dd1c6fa738618294388cc6e8c9ec48c3541c Mon Sep 17 00:00:00 2001 From: kikito Date: Tue, 11 Aug 2015 19:15:00 +0200 Subject: [PATCH] Implements User#organization? and User#verified_organization? --- app/models/user.rb | 8 ++++++++ spec/models/user_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 4eb832546..c6e477815 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -27,4 +27,12 @@ class User < ActiveRecord::Base def moderator? @is_moderator ||= Moderator.where(user_id: id).exists? end + + def organization? + organization_name.present? + end + + def verified_organization? + organization_verified_at.present? + end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 4a8fe8fd7..b57595660 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -111,4 +111,24 @@ describe User do end end + describe "organization?" do + it "is false when organization_name is blank" do + expect(subject.organization?).to be false + end + it "is true when organization_name exists" do + subject.organization_name = "Anonymous" + expect(subject.organization?).to be true + end + end + + describe "verified_organization?" do + it "is false when organization_verified_at? is blank" do + expect(subject.verified_organization?).to be false + end + it "is true when organization_verified_at? exists" do + subject.organization_verified_at = Time.now + expect(subject.verified_organization?).to be true + end + end + end