Skip to content

Commit

Permalink
Uses polymorphic_path([snap, :snapshots]) and self.class.model_name.h…
Browse files Browse the repository at this point in the history
…uman
  • Loading branch information
fherreazcue authored and stuzart committed Sep 28, 2023
1 parent 7ad3ac6 commit 3133efa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/seek/research_objects/acts_as_snapshottable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def is_snapshottable?
module InstanceMethods
def create_snapshot
if self.creators.empty?
errors.add(:base, "At least one creator is required. To add, go to Actions -> Manage #{self.class.name}.")
errors.add(:base, "At least one creator is required. To add, go to Actions -> Manage #{self.class.model_name.human}.")
return nil
end
Rails.logger.debug("Creating snapshot for: #{self.class.name} #{id}")
Expand Down
5 changes: 3 additions & 2 deletions test/functional/snapshots_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ class SnapshotsControllerTest < ActionController::TestCase
contributor: user.person, creators: [])

login_as(user)
[study, investigation, assay].each do |snap|
[investigation, study, assay].each do |snap|
assert snap.can_manage?(user)
assert snap.creators.empty?
type = snap.class.name.underscore
request.path = Seek::Util.routes.polymorphic_path(snap)+"/snapshots"
# Updating the request.path is needed so that @resource is correctly set, and the snapshots is created for the correct item in the loop
request.path = Seek::Util.routes.polymorphic_path([snap, :snapshots])
# Get preview
get :new, params: { "#{type}_id": snap.id }
assert_response :success
Expand Down

0 comments on commit 3133efa

Please sign in to comment.