Skip to content

Commit e9c5700

Browse files
author
John Pinto
committed
Updated tests for changes to Conditional Questions code.
1 parent 44666cb commit e9c5700

File tree

6 files changed

+1235
-3
lines changed

6 files changed

+1235
-3
lines changed

spec/controllers/answers_controller_with_conditional_questions_spec.rb

Lines changed: 540 additions & 0 deletions
Large diffs are not rendered by default.

spec/factories/answers.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,11 @@
3434
plan
3535
user
3636
question
37+
trait :question_options do
38+
question_options { [create(:question_option)] }
39+
end
40+
trait :lock_version do
41+
lock_version { 0 }
42+
end
3743
end
3844
end

spec/factories/conditions.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,22 @@
2626

2727
FactoryBot.define do
2828
factory :condition do
29-
option_list { nil }
30-
remove_data { nil }
29+
option_list { [] }
30+
remove_data { [] }
31+
action_type { nil }
32+
# the webhook_data is a Json string of form:
33+
# '{"name":"Joe Bloggs","email":"[email protected]","subject":"Large data volume","message":"A message."}'
34+
trait :webhook do
35+
action_type { 'add_webhook' }
36+
webhook_data do
37+
# Generates string from hash
38+
JSON.generate({
39+
name: Faker::Name.name,
40+
email: Faker::Internet.email,
41+
subject: Faker::Lorem.sentence(word_count: 4),
42+
message: Faker::Lorem.paragraph(sentence_count: 2)
43+
})
44+
end
45+
end
3146
end
3247
end

0 commit comments

Comments
 (0)