-
Notifications
You must be signed in to change notification settings - Fork 897
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |