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