spec/support/shared_examples/signature/shared/field_methods.rb in groupdocs-1.2.3 vs spec/support/shared_examples/signature/shared/field_methods.rb in groupdocs-1.2.6
- old
+ new
@@ -40,11 +40,11 @@
mock_api_server(load_json('signature_field_add'))
end
it 'accepts access credentials hash' do
lambda do
- subject.add_field!(field, document, recipient, client_id: 'client_id', private_key: 'private_key')
+ subject.add_field!(field, document, recipient, { force_new_field: false }, client_id: 'client_id', private_key: 'private_key')
end.should_not raise_error(ArgumentError)
end
it 'raises error if field is not GroupDocs::Signature::Field object' do
-> { subject.add_field!('Field', document, recipient) }.should raise_error(ArgumentError)
@@ -61,18 +61,29 @@
it 'raises error if field does not specify location' do
field = GroupDocs::Signature::Field.new
-> { subject.add_field!(field, document, recipient) }.should raise_error(ArgumentError)
end
- it 'uses field, field location and forcedNewField flag as payload' do
+ it 'uses field and field locationas payload' do
hash_one = {}
payload = {}
location = {}
field.should_receive(:to_hash).and_return(payload)
field.location.should_receive(:to_hash).and_return(location)
payload.should_receive(:merge!).with(location).and_return(payload)
payload.should_receive(:merge!).with(forceNewField: true).and_return({})
subject.add_field!(field, document, recipient)
+ end
+
+ it 'allows overriding force new field flag' do
+ hash_one = {}
+ payload = {}
+ location = {}
+ field.should_receive(:to_hash).and_return(payload)
+ field.location.should_receive(:to_hash).and_return(location)
+ payload.should_receive(:merge!).with(location).and_return(payload)
+ payload.should_receive(:merge!).with(forceNewField: false).and_return({})
+ subject.add_field!(field, document, recipient, force_new_field: false)
end
end
describe '#modify_field!' do
let(:field) { GroupDocs::Signature::Field.new }