Skip to content

Commit

Permalink
Merge pull request #13854 from CartoDB/deprecated_job_roles
Browse files Browse the repository at this point in the history
Deprecated job roles
  • Loading branch information
Javier Torres committed Apr 17, 2018
2 parents ba0c950 + c109856 commit 60d71cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/models/user.rb
Expand Up @@ -60,6 +60,9 @@ class User < Sequel::Model
JOB_ROLES = ['Founder / Executive', 'Developer', 'Student', 'VP / Director', 'Manager / Lead',
'Personal / Non-professional', 'Media', 'Individual Contributor'].freeze

DEPRECATED_JOB_ROLES = ['Researcher', 'GIS specialist', 'Designer', 'Consultant / Analyst',
'CIO / Executive', 'Marketer', 'Sales', 'Journalist', 'Hobbyist'].freeze

# Make sure the following date is after Jan 29, 2015,
# which is the date where a message to accept the Terms and
# conditions and the Privacy policy was included in the Signup page.
Expand Down Expand Up @@ -186,7 +189,7 @@ def validate
end

validates_includes INDUSTRIES, :industry if industry.present?
validates_includes JOB_ROLES, :job_role if job_role.present?
validates_includes JOB_ROLES + DEPRECATED_JOB_ROLES, :job_role if job_role.present?

errors.add(:geocoding_quota, "cannot be nil") if geocoding_quota.nil?
errors.add(:here_isolines_quota, "cannot be nil") if here_isolines_quota.nil?
Expand Down
18 changes: 18 additions & 0 deletions spec/models/user_spec.rb
Expand Up @@ -453,6 +453,24 @@ def create_role(user)
user.destroy
end

it "should validate job_role and deprecated_job_roles" do
user = ::User.new
user.username = "adminipop"
user.email = "adminipop@example.com"
user.password = 'admin123'
user.password_confirmation = 'admin123'

user.job_role = "Developer"
user.valid?.should be_true

user.job_role = "Researcher"
user.valid?.should be_true

user.job_role = "whatever"
user.valid?.should be_false
user.errors[:job_role].should be_present
end

it "should validate password presence and length" do
user = ::User.new
user.username = "adminipop"
Expand Down

0 comments on commit 60d71cc

Please sign in to comment.