Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restoring anonymous resource declaration in specs #4493

Commits on Sep 2, 2020

  1. Restoring anonymous resource declaration in specs

    At issue is "human_readable_type" leverages the resource's model name,
    which, by default, uses ActiveModel::Name.  By adding `.model_name` that
    returns an instance of ActiveModel::Name, the tests now pass.
    
    I could imagine adding a spec helper method for generating an anonymous
    resource.  This method would encapsulate the behavior.  If we were to go
    this route, we'd want to update all of our existing `Class.new` declarations.
    
    ```ruby
    module Hyrax::SpecSupport
      def self.build_anonymous_resource_class(klass, name: "Anonymous", &block)
         Class.new(klass) do
           def self.model_name
             ActiveModel::Name.new(self, nil, name)
           end
           instance_exec(&block)
         end
      end
    end
    
    Hyrax::SpecSupport.build_anonymous_resource_class(Hyrax::Work, name: "Anonymouse") do
      include Hyrax::Schema(:basic_metadata)
    end
    ```
    jeremyf committed Sep 2, 2020
    Configuration menu
    Copy the full SHA
    4e05a16 View commit details
    Browse the repository at this point in the history