Skip to content

Commit

Permalink
Merge pull request #337 from samvera-labs/i#329
Browse files Browse the repository at this point in the history
Calling super instead of a specific class
  • Loading branch information
escowles committed Dec 18, 2017
2 parents c3060dd + a979f11 commit cccdf66
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/valkyrie/resource.rb
Expand Up @@ -15,7 +15,7 @@ class Resource < Dry::Struct
# Overridden to provide default attributes.
# @note The current theory is that we should use this sparingly.
def self.inherited(subclass)
::Dry::Struct.inherited(subclass)
super(subclass)
subclass.constructor_type :schema
subclass.attribute :internal_resource, Valkyrie::Types::Any.default(subclass.to_s)
subclass.attribute :created_at, Valkyrie::Types::DateTime.optional
Expand Down
16 changes: 16 additions & 0 deletions spec/valkyrie/resource_spec.rb
Expand Up @@ -76,4 +76,20 @@ class Resource < Valkyrie::Resource
expect(resource.to_s).to eq "Resource: test"
end
end

context "extended class" do
before do
class MyResource < Resource
end
end
after do
Object.send(:remove_const, :MyResource)
end
subject(:resource) { MyResource.new }
describe "#fields" do
it "returns all configured parent fields as an array of symbols" do
expect(MyResource.fields).to eq [:internal_resource, :created_at, :updated_at, :id, :title]
end
end
end
end

0 comments on commit cccdf66

Please sign in to comment.