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

Fixes #622: Valkyrie ID should equal string equivalent of ID to string #782

Merged
merged 3 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/valkyrie/id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def to_s
delegate :hash, to: :state

def eql?(other)
other.class == self.class && other.state == state
(other.class == self.class && other.state == state) ||
(other.to_s == to_s)
end
alias == eql?

Expand Down
4 changes: 4 additions & 0 deletions spec/valkyrie/types_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class Resource < Valkyrie::Resource
it 'casts to a string' do
expect(resource.thumbnail_id).to eq Valkyrie::ID.new('123')
end

it 'equals the equivalent string if ID matches string' do
expect(resource.thumbnail_id).to eq '123'
end
end

context 'when an ID is passed in' do
Expand Down