Skip to content

Commit

Permalink
More work on tests.
Browse files Browse the repository at this point in the history
modified:   app/controllers/application_controller.rb
modified:   app/models/analysis_item.rb
modified:   app/models/analysis_job.rb
modified:   app/models/analysis_script.rb
modified:   app/models/audio_event.rb
modified:   app/models/audio_recording.rb
modified:   app/models/bookmark.rb
modified:   app/models/photo.rb
modified:   app/models/progress.rb
modified:   app/models/project.rb
modified:   app/models/site.rb
modified:   app/models/tag.rb
modified:   app/models/user.rb
modified:   spec/factories/analysis_job_factory.rb
modified:   spec/factories/analysis_script_factory.rb
modified:   spec/factories/audio_event_factory.rb
modified:   spec/factories/bookmark_factory.rb
modified:   spec/factories/permission_factory.rb
modified:   spec/factories/saved_search_factory.rb
modified:   spec/factories/tag_factory.rb
modified:   spec/spec_helper.rb
modified:   spec/support/api_examples_delete.rb
  • Loading branch information
Mark Cottman-Fields committed Feb 4, 2013
1 parent c67af6d commit 8c3be6d
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 18 deletions.
6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def render_csv(filename = nil)
end

def add_archived_at_header(model)
#if model.respond_to?(:deleted_at) && !model.deleted_at.blank?
response.headers["X-Archived-At"] = 'hi'#model.deleted_at
#end
if model.respond_to?(:deleted_at) && !model.deleted_at.blank?
response.headers["X-Archived-At"] = model.deleted_at
end
end

def no_content_as_json
Expand Down
3 changes: 3 additions & 0 deletions app/models/analysis_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class AnalysisItem < ActiveRecord::Base
enumerize :status, in: AVAILABLE_STATUSES, :default => :ready, predicates: true
validates :status, inclusion: {in: AVAILABLE_STATUSES}, presence: true


# userstamp not used

# validations
validates :offset_start_seconds, presence: true, numericality: {greater_than_or_equal_to: 0}
validates :offset_end_seconds, presence: true, numericality: {greater_than_or_equal_to: 0}
Expand Down
2 changes: 2 additions & 0 deletions app/models/analysis_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ class AnalysisJob < ActiveRecord::Base
accepts_nested_attributes_for :saved_search

# userstamp
acts_as_paranoid
stampable
belongs_to :user, class_name: 'User', foreign_key: :creator_id
validates_as_paranoid

# validations
validates :name, presence: true, length: { minimum: 2, maximum: 255 }, uniqueness: { case_sensitive: false }
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 @@ -33,9 +33,9 @@ def initialize(attributes = nil, options = {})
# TODO: THIS FIELD SHOULD BE RESTRICTED

# userstamp
acts_as_paranoid
stampable
belongs_to :user, :class_name => 'User', :foreign_key => :creator_id
acts_as_paranoid
validates_as_paranoid

# validations
Expand Down
2 changes: 1 addition & 1 deletion app/models/audio_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class AudioEvent < ActiveRecord::Base
:tags_attributes

# userstamp
acts_as_paranoid
stampable
belongs_to :user, class_name: 'User', foreign_key: :creator_id
acts_as_paranoid
validates_as_paranoid

# validation
Expand Down
6 changes: 3 additions & 3 deletions app/models/audio_recording.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AudioRecording < ActiveRecord::Base
# relations
belongs_to :site
has_many :audio_events
belongs_to :user, :class_name => 'User', :foreign_key => "uploader_id"
belongs_to :user, :class_name => 'User', :foreign_key => :uploader_id
has_many :analysis_items
has_many :bookmarks

Expand All @@ -23,9 +23,9 @@ class AudioRecording < ActiveRecord::Base
accepts_nested_attributes_for :site

# userstamp
stampable
belongs_to :user, :class_name => 'User', :foreign_key => :creator_id
acts_as_paranoid
stampable
belongs_to :user, class_name: 'User', foreign_key: :creator_id
validates_as_paranoid

#enums
Expand Down
2 changes: 1 addition & 1 deletion app/models/bookmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Bookmark < ActiveRecord::Base

# userstamp
stampable
belongs_to :user, :class_name => 'User', :foreign_key => :creator_id
belongs_to :user, class_name: 'User', foreign_key: :creator_id

# validation
validates :offset_seconds, :presence => true, :numericality => { :greater_than_or_equal_to => 0 }
Expand Down
4 changes: 4 additions & 0 deletions app/models/photo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ class Photo < ActiveRecord::Base
# attr
attr_accessible :copyright, :uri, :description, :imageable_type, :imageable_id

# userstamp
stampable
belongs_to :user, class_name: 'User', foreign_key: :creator_id

# validation
# http://stackoverflow.com/questions/6778269/rails-3-polymorphic-liking-of-entities-by-user-how
# http://stackoverflow.com/questions/746387/labels-for-radio-buttons-in-rails-form
Expand Down
2 changes: 1 addition & 1 deletion app/models/progress.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Progress < ActiveRecord::Base

# userstamp
stampable
belongs_to :user, :class_name => 'User', :foreign_key => :creator_id
belongs_to :user, class_name: 'User', foreign_key: :creator_id

# validation
validates_uniqueness_of :activity,
Expand Down
4 changes: 2 additions & 2 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class Project < ActiveRecord::Base


# userstamp
stampable
belongs_to :user, :class_name => 'User', :foreign_key => :creator_id
acts_as_paranoid
stampable
belongs_to :user, class_name: 'User', foreign_key: :creator_id
validates_as_paranoid

# validation
Expand Down
4 changes: 2 additions & 2 deletions app/models/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class Site < ActiveRecord::Base
accepts_nested_attributes_for :audio_recordings

# userstamp
stampable
belongs_to :user, :class_name => 'User', :foreign_key => :creator_id
acts_as_paranoid
stampable
belongs_to :user, class_name: 'User', foreign_key: :creator_id
validates_as_paranoid

# validations
Expand Down
2 changes: 0 additions & 2 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class Tag < ActiveRecord::Base
# userstamp
stampable
belongs_to :user, class_name: 'User', foreign_key: :creator_id
#acts_as_paranoid # deletable, not archiveable
#validates_as_paranoid

# enums
AVAILABLE_TYPE_OF_TAGS = [:common_name, :species_name, :looks_like, :sounds_like].map{ |item| item.to_s }
Expand Down
7 changes: 5 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ class User < ActiveRecord::Base



# user stamp
model_stamper
# userstamp
model_stamper # this identifies this class as being the class that 'stamps'
acts_as_paranoid
stampable
belongs_to :user, class_name: 'User', foreign_key: :creator_id
validates_as_paranoid

# other associations
has_many :authorizations, :dependent => :destroy
Expand Down

0 comments on commit 8c3be6d

Please sign in to comment.