This repository was archived by the owner on Jun 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest_forms.rb
More file actions
104 lines (84 loc) · 3.53 KB
/
test_forms.rb
File metadata and controls
104 lines (84 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
class FormsTest < TestBase
def test_all_requests
form = Form.full_example
create_form = CreateFormRequest.new(form)
assert_equal create_form.success?, true
assert_equal form.same?(create_form.form), true
form = create_form.form
retrieve_form = RetrieveFormRequest.new(form)
assert_equal retrieve_form.success?, true
assert_equal form.same?(retrieve_form.form), true
form = retrieve_form.form
head_form = HeadFormRequest.new(form)
assert_equal head_form.success?, true
retrieve_all_forms = RetrieveAllFormsRequest.new
assert_equal retrieve_all_forms.success?, true
update_form = UpdateFormRequest.new(form)
assert_equal update_form.success?, true
assert_equal form.same?(update_form.form), true
form = update_form.form
patch_operations = [PatchOperation.new(op: 'replace', path: '/title', value: 'new title')]
update_patch_form = UpdateFormPatchRequest.new(form, patch_operations)
assert_equal update_patch_form.success?, true
delete_form = DeleteFormRequest.new(form)
assert_equal delete_form.success?, true
end
def test_form_same_method
form = Form.full_example
same_form = form.dup
assert_equal form.same?(same_form), true
different_form = form.dup
different_form.title = DataGenerator.title
assert_equal form.same?(different_form), false
end
def test_block_same_method
block = ShortTextBlock.full_example
same_block = block.dup
assert_equal block.same?(same_block), true
different_block = block.dup
different_block.ref = DataGenerator.field_ref
assert_equal block.same?(different_block), false
end
def test_logic_same_method
logic_jump = LogicJump.create_always_jump(Form.full_example)
same_logic_jump = logic_jump.dup
assert_equal logic_jump.same?(same_logic_jump), true
different_logic_jump = logic_jump.dup
different_logic_jump.to_ref = DataGenerator.field_ref
assert_equal logic_jump.same?(different_logic_jump), false
end
def test_settings_same_method
settings = Settings.full_example(DataGenerator.field_ref)
same_settings = settings.dup
assert_equal settings.same?(same_settings), true
different_settings = settings.dup
different_settings.is_public = false
assert_equal settings.same?(different_settings), false
end
def test_messages
form = CreateFormRequest.execute(Form.new).form
retrieve_messages = RetrieveMessagesRequest.new(form)
assert_equal retrieve_messages.success?, true
messages = Messages.new('label.button.ok' => 'New Ok')
update_messages = UpdateMessagesRequest.new(form, messages)
assert_equal update_messages.success?, true
assert_equal messages.same?(RetrieveMessagesRequest.execute(form).messages), true
DeleteFormRequest.execute(form)
end
end