Implements User#organization? and User#verified_organization?

This commit is contained in:
kikito
2015-08-11 19:15:00 +02:00
parent 3551b55bdd
commit 83e3dd1c6f
2 changed files with 28 additions and 0 deletions

View File

@@ -27,4 +27,12 @@ class User < ActiveRecord::Base
def moderator? def moderator?
@is_moderator ||= Moderator.where(user_id: id).exists? @is_moderator ||= Moderator.where(user_id: id).exists?
end end
def organization?
organization_name.present?
end
def verified_organization?
organization_verified_at.present?
end
end end

View File

@@ -111,4 +111,24 @@ describe User do
end end
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 end