Skip to content
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: 3 additions & 0 deletions lib/draper/compatibility/global_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module GlobalID

included do
include ::GlobalID::Identification

# NOTE: Ensure turbo stream names are generated based on decorated object
delegate :to_gid_param, :to_sgid_param, to: :object
end

class_methods do
Expand Down
20 changes: 20 additions & 0 deletions spec/dummy/spec/models/post_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@

it { should be_a ApplicationRecord }

describe '#to_gid_param' do
let(:post) { Post.create }
subject { post.to_gid_param }

it { is_expected.to eq post.decorate.to_gid_param }
end

describe '#to_sgid_param' do
include ActiveSupport::Testing::TimeHelpers

let(:post) { Post.create }
subject { post.to_sgid_param }

around do |example|
freeze_time { example.run }
end

it { is_expected.to eq post.decorate.to_sgid_param }
end

describe 'broadcasts' do
let(:modification) { described_class.create! }

Expand Down
Loading