Skip to content

Commit

Permalink
PAUSED: Use git resume to continue working.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmcculloug committed Mar 29, 2018
1 parent 37b707e commit 962aa1f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/models/service/dialog_properties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ def apply_dialog_settings
retires_in_days
retires_in_hours
).each do |field_name|
dialog_field_name = "dialog_service_#{field_name}"
send(dialog_field_name, dialog_options[dialog_field_name]) if dialog_options.key?(dialog_field_name)
begin
dialog_field_name = "dialog_service_#{field_name}"
dialog_field_value = dialog_options[dialog_field_name]
send(dialog_field_name, dialog_field_value) if dialog_options.key?(dialog_field_name)
rescue => err
_log.error("Error setting key [#{dialog_field_name}] with value [#{dialog_field_value.inspect}] error: [#{err}]")
end
end
end

Expand Down
24 changes: 24 additions & 0 deletions spec/models/service/dialog_properties_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,28 @@
.to eq('test description from dialog')
end
end

context 'service retires_on' do
it 'without empty options hash' do
expect(Service.create(:name => 'test').retires_on).to be_nil
end

# it 'with empty dialog options' do
# expect(Service.create(:name => 'test',
# :description => 'test description',
# :options => {:dialog => {}}).description)
# .to eq('test description')
# end

it 'with dialog option dialog_service_description' do
time = Time.new(2017, 12, 1, 0, 0, 0, 0)
Timecop.freeze(time) do
expect(Service.create(:name => 'test',
:options => {
:dialog => {'dialog_service_retires_on' => time.to_s}
}).retires_on)
.to eq(time)
end
end
end
end

0 comments on commit 962aa1f

Please sign in to comment.