fix expectations

- when the value is '' we should expect '' and not nil (IMO the old implementation was flawed)
- do not care whether find_by_id is called with string or int
pull/2889/head
Jan Sandbrink 10 years ago
parent c6ea6c6b4d
commit 0924835bcd
  1. 7
      spec/decorators/api/experimental/work_package_decorator_spec.rb

@ -54,7 +54,7 @@ describe API::Experimental::WorkPackageDecorator, type: :model do
end
describe '#custom_values_display_data' do
it 'returns a hash with a subset of information about the custom value' do
it 'returns a hash with a subset of information about a custom value' do
allow(dwp1).to receive(:custom_values).and_return [custom_value]
returned = dwp1.custom_values_display_data(custom_field.id)
@ -62,18 +62,19 @@ describe API::Experimental::WorkPackageDecorator, type: :model do
expected = [{
custom_field_id: custom_field.id,
field_format: custom_field.field_format,
value: nil
value: ''
}]
expect(returned).to eql (expected)
end
it 'returns a hash with a subset of information about the custom value' do
it 'returns a hash with a subset of information about a user custom value' do
field = FactoryGirl.build_stubbed(:user_issue_custom_field)
custom_value.custom_field = field
user = FactoryGirl.build_stubbed(:user)
custom_value.value = user.id.to_s
allow(User).to receive(:find_by_id).with(user.id).and_return(user)
allow(User).to receive(:find_by_id).with(user.id.to_s).and_return(user)
allow(dwp1).to receive(:custom_values).and_return [custom_value]

Loading…
Cancel
Save