From 51a670e32ba30dc46bf74da98cbdb8594f71718d Mon Sep 17 00:00:00 2001 From: Joachim Filip Ignacy Bartosik Date: Fri, 13 Aug 2010 17:10:49 +0200 Subject: Move Role where it belongs to app/rich_types --- app/models/guest.rb | 2 +- app/models/role.rb | 1 - app/models/user.rb | 6 +++--- app/rich_types/role.rb | 3 +++ features/step_definitions/users_steps.rb | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 app/models/role.rb create mode 100644 app/rich_types/role.rb diff --git a/app/models/guest.rb b/app/models/guest.rb index 4348c85..2c01803 100644 --- a/app/models/guest.rb +++ b/app/models/guest.rb @@ -10,7 +10,7 @@ class Guest < Hobo::Guest def nick; nil; end def project_lead; false; end def questions_to_approve; []; end - def role; Role.new(:guest); end + def role; RichTypes::Role.new(:guest); end def token; nil; end def valid?; true; end def save!; true; end diff --git a/app/models/role.rb b/app/models/role.rb deleted file mode 100644 index 4e122d9..0000000 --- a/app/models/role.rb +++ /dev/null @@ -1 +0,0 @@ -Role = HoboFields::EnumString.for(:recruit, :mentor, :recruiter) diff --git a/app/models/user.rb b/app/models/user.rb index 078c37c..828840f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -12,7 +12,7 @@ class User < ActiveRecord::Base name :string, :required, :unique email_address :email_address, :login => true administrator :boolean, :default => false - role Role, :default => 'recruit' + role RichTypes::Role, :default => 'recruit' nick :string openid :string contributions HoboFields::MarkdownString @@ -215,8 +215,8 @@ class User < ActiveRecord::Base # and make sure change to role wasn't changed or was promotion of recruit # to mentor or demotion of mentor to recruit return true unless role_changed? - return true if role.is_mentor? && Role.new(role_was).is_recruit? - return true if role.is_recruit? && Role.new(role_was).is_mentor? + return true if role.is_mentor? && RichTypes::Role.new(role_was).is_recruit? + return true if role.is_recruit? && RichTypes::Role.new(role_was).is_mentor? false end diff --git a/app/rich_types/role.rb b/app/rich_types/role.rb new file mode 100644 index 0000000..c69627d --- /dev/null +++ b/app/rich_types/role.rb @@ -0,0 +1,3 @@ +module RichTypes + Role = HoboFields::EnumString.for(:recruit, :mentor, :recruiter) +end diff --git a/features/step_definitions/users_steps.rb b/features/step_definitions/users_steps.rb index 4493402..932e538 100644 --- a/features/step_definitions/users_steps.rb +++ b/features/step_definitions/users_steps.rb @@ -8,7 +8,7 @@ end Given /^(?:|a )user "([^\"]*)" who is "([^\"]*)"$/ do |user, role| Given "user \"#{user}\"" - @user.role = Role.new(role) + @user.role = RichTypes::Role.new(role) @user.save! end -- cgit v1.2.3-65-gdbad