aboutsummaryrefslogtreecommitdiffstats
path: root/spec/factories
diff options
context:
space:
mode:
Diffstat (limited to 'spec/factories')
-rw-r--r--spec/factories/censor_rules.rb32
-rw-r--r--spec/factories/outgoing_messages.rb19
-rw-r--r--spec/factories/public_body_categories.rb8
-rw-r--r--spec/factories/public_body_category_links.rb6
-rw-r--r--spec/factories/public_body_headings.rb5
5 files changed, 69 insertions, 1 deletions
diff --git a/spec/factories/censor_rules.rb b/spec/factories/censor_rules.rb
new file mode 100644
index 000000000..2c0b2c822
--- /dev/null
+++ b/spec/factories/censor_rules.rb
@@ -0,0 +1,32 @@
+FactoryGirl.define do
+
+ factory :censor_rule do
+ text 'some text to redact'
+ replacement '[REDACTED]'
+ last_edit_editor 'FactoryGirl'
+ last_edit_comment 'Modified by rspec'
+
+ factory :regexp_censor_rule do
+ text '\w+@\w+'
+ regexp true
+ end
+
+ factory :info_request_censor_rule do
+ info_request
+ end
+
+ factory :public_body_censor_rule do
+ public_body
+ end
+
+ factory :user_censor_rule do
+ user
+ end
+
+ factory :global_censor_rule do
+ initialize_with { CensorRule.new(:allow_global => true) }
+ end
+
+ end
+
+end
diff --git a/spec/factories/outgoing_messages.rb b/spec/factories/outgoing_messages.rb
index d1ed25093..e11cbdfb9 100644
--- a/spec/factories/outgoing_messages.rb
+++ b/spec/factories/outgoing_messages.rb
@@ -1,6 +1,8 @@
FactoryGirl.define do
factory :outgoing_message do
+ info_request
+
factory :initial_request do
ignore do
status 'ready'
@@ -8,7 +10,9 @@ FactoryGirl.define do
body 'Some information please'
what_doing 'normal_sort'
end
+
end
+
factory :internal_review_request do
ignore do
status 'ready'
@@ -16,14 +20,27 @@ FactoryGirl.define do
body 'I want a review'
what_doing 'internal_review'
end
+
end
+
+ # FIXME: This here because OutgoingMessage has an after_initialize,
+ # which seems to call everything in the app! FactoryGirl calls new with
+ # no parameters and then uses the assignment operator of each attribute
+ # to update it. Because after_initialize executes before assigning the
+ # attributes, loads of stuff fails because whatever after_initialize is
+ # doing expects some of the attributes to be there.
initialize_with { OutgoingMessage.new({ :status => status,
:message_type => message_type,
:body => body,
:what_doing => what_doing }) }
+
after_create do |outgoing_message|
- outgoing_message.send_message
+ outgoing_message.sendable?
+ outgoing_message.record_email_delivery(
+ 'test@example.com',
+ 'ogm-14+537f69734b97c-1ebd@localhost')
end
+
end
end
diff --git a/spec/factories/public_body_categories.rb b/spec/factories/public_body_categories.rb
new file mode 100644
index 000000000..baa474c6b
--- /dev/null
+++ b/spec/factories/public_body_categories.rb
@@ -0,0 +1,8 @@
+
+FactoryGirl.define do
+ factory :public_body_category do
+ sequence(:title) { |n| "Example Public Body Category #{n}" }
+ sequence(:category_tag) { |n| "example_tag_#{n}" }
+ sequence(:description) { |n| "Example Public body Description #{n}" }
+ end
+end
diff --git a/spec/factories/public_body_category_links.rb b/spec/factories/public_body_category_links.rb
new file mode 100644
index 000000000..7663b1f52
--- /dev/null
+++ b/spec/factories/public_body_category_links.rb
@@ -0,0 +1,6 @@
+FactoryGirl.define do
+ factory :public_body_category_link do
+ association :public_body_category
+ association :public_body_heading
+ end
+end
diff --git a/spec/factories/public_body_headings.rb b/spec/factories/public_body_headings.rb
new file mode 100644
index 000000000..ed54ddada
--- /dev/null
+++ b/spec/factories/public_body_headings.rb
@@ -0,0 +1,5 @@
+FactoryGirl.define do
+ factory :public_body_heading do
+ sequence(:name) { |n| "Example Public Body Heading #{n}" }
+ end
+end