Skip to content

Commit

Permalink
Add test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
lfu committed Aug 22, 2018
1 parent cef223a commit 4b2afee
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions spec/models/custom_button_event_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
describe CustomButtonEvent do
let(:custom_button) { FactoryGirl.create(:custom_button, :applies_to_class => "Vm", :name => "Test Button") }
let(:ae_entry_point) { "/SYSTEM/PROCESS/Request" }
let(:cb_event) do
FactoryGirl.create(:custom_button_event,
:full_data => {
:automate_entry_point => ae_entry_point,
:button_id => custom_button.id,
:button_name => custom_button.name
})
end

context '#automate_entry_point' do
it 'returns a string' do
expect(cb_event.automate_entry_point).to eq(ae_entry_point)
end

it 'returns an empty string' do
cb_event.full_data.delete(:automate_entry_point)
cb_event.save!

expect(cb_event.automate_entry_point).to eq("")
end
end

context '#button_name' do
it "returns button's current name" do
expect(cb_event.button_name).to eq("Test Button")

custom_button.update_attributes(:name => "New Button Name")
expect(cb_event.button_name).to eq("New Button Name")
end

it 'returns button name from event data' do
cb_event.full_data[:button_id] = custom_button.id - 1
cb_event.save!
custom_button.update_attributes(:name => "New Button Name")

expect(cb_event.button_name).to eq("Test Button")
end
end
end

0 comments on commit 4b2afee

Please sign in to comment.