Skip to content

Commit

Permalink
Add CustomButtonEvent association to GenericObject.
Browse files Browse the repository at this point in the history
  • Loading branch information
lfu committed Aug 29, 2018
1 parent 0f4f7b1 commit 5c06f88
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/generic_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class GenericObject < ApplicationRecord

belongs_to :generic_object_definition
has_one :picture, :through => :generic_object_definition
has_many :custom_button_events, -> { where(:type => "CustomButtonEvent") }, :class_name => "EventStream", :foreign_key => :target_id

validates :name, :presence => true

Expand Down
8 changes: 8 additions & 0 deletions spec/models/generic_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,5 +376,13 @@
go.custom_action_buttons
end
end

describe '#custom_button_events' do
let(:cb_event) { FactoryGirl.create(:custom_button_event, :target => go) }

it 'returns list of custom button events' do
expect(go.custom_button_events).to match_array([cb_event])
end
end
end
end

0 comments on commit 5c06f88

Please sign in to comment.