Skip to content

Commit

Permalink
Fixed bugs with seeds and models, upfraded acts_as_paranoid
Browse files Browse the repository at this point in the history
modified:   Gemfile
modified:   Gemfile.lock

modified:   app/models/analysis_job.rb
modified:   app/models/analysis_script.rb
modified:   app/models/tag.rb
	-- %w constructs changed to native types

modified:   db/seeds.rb
modified:   app/models/user.rb
	-- added the ability to skip validation of user_name when seeding

modified:   db/development_seeds.rb
	-- fixed a few broken seed statements
  • Loading branch information
atruskie committed Dec 18, 2012
1 parent 7d432b4 commit 94e6cd9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/analysis_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AnalysisJob < ActiveRecord::Base
validates :script_settings, :presence => true
validates :script_version, :presence => true
validates :script_display_name, :presence => true
validates :process_new, :inclusion => { :in => %w(true false) }
validates :process_new, :inclusion => { :in => [true, false] }
validate :data_set_cannot_process_new

# custom validation methods
Expand Down
2 changes: 1 addition & 1 deletion app/models/analysis_script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class AnalysisScript < ActiveRecord::Base
validates :settings, :presence => true
validates :version, :presence => true
validates :display_name, :presence => true
validates :verified, :inclusion => { :in => %w(true false) }
validates :verified, :inclusion => { :in => [true, false] }

end
2 changes: 1 addition & 1 deletion app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Tag < ActiveRecord::Base
enumerize :type_of_tag, :in => [:common_name, :species_name, :looks_like, :sounds_like], predicates: true

# validation
validates :is_taxanomic, :inclusion => { :in => %w(true false) }
validates :is_taxanomic, :inclusion => { :in => [true, false] }
validates :text, :uniqueness => { :case_sensitive => false }
#validate :class_mutually_exclusive_with_tag_type

Expand Down
12 changes: 11 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class User < ActiveRecord::Base

# Setup accessible (or protected) attributes for your model
attr_accessible :user_name, :display_name, :email, :password, :admin

has_many :authorizations, :dependent => :destroy

# user stamp
Expand All @@ -28,9 +29,18 @@ class User < ActiveRecord::Base
#:format => { :with => /\A[a-zA-Z0-9_ ]+\z/, :message => "only letters, numbers, space and underscore allowed" }
validates :display_name, :uniqueness => {:case_sensitive => false }, :presence => { :unless => Proc.new { |a| a.email.present? }, :message => "Please provide a name, email, or both." }
validates :email, :uniqueness => {:case_sensitive => false }, :presence => { :unless => Proc.new { |a| a.display_name.present? }, :message => "Please provide an email, name, or both." }
validates :user_name, :exclusion => { :in => %w(admin harvester analysis_runner) }
validates :user_name, :exclusion => { :in => %w(admin harvester analysis_runner) }, :unless => :skip_user_name_exclusion_list
#friendly_id :display_name, :use_slug => true, :strip_non_ascii => true


# special vanlidation skip
# TODO: does this need some protectection?
def skip_user_name_exclusion_list=(value)
@skip_user_name_exclusion_list = value
end

def skip_user_name_exclusion_list
@skip_user_name_exclusion_list
end

end

0 comments on commit 94e6cd9

Please sign in to comment.