diff options
| author | Teddy Wing | 2017-06-23 12:00:50 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-06-23 12:11:02 +0200 |
| commit | b7077970a244d00f59ce797ef5b36be774ca3802 (patch) | |
| tree | c20becf098c31d826846c67a2c6f507641a4eb1e | |
| parent | 763ba5430c9babc38ef816f9cd3b4abe9b250f88 (diff) | |
| download | chouette-core-b7077970a244d00f59ce797ef5b36be774ca3802.tar.bz2 | |
Split factories from chouette_2_factories.rb
Split out all the factories defined in this file into their own separate
files. This helps to make our factories more consistent, so we don't
have a bunch of newer factories in their own files and another bunch of
factories from the early days (presumably) of the application, which are
defined in a single file.
This came about because I was looking for a Referential factory, and was
surprised to not see one defined. Then Xin showed me this grouped
factory file, and I saw that it actually does exist. With this change,
the factories will better match expectations.
| -rw-r--r-- | spec/factories/chouette_2_factories.rb | 80 | ||||
| -rw-r--r-- | spec/factories/compliance_check_results.rb | 8 | ||||
| -rw-r--r-- | spec/factories/compliance_check_tasks.rb | 8 | ||||
| -rw-r--r-- | spec/factories/export_log_messages.rb | 6 | ||||
| -rw-r--r-- | spec/factories/exports.rb | 5 | ||||
| -rw-r--r-- | spec/factories/import_tasks.rb | 10 | ||||
| -rw-r--r-- | spec/factories/kml_exports.rb | 5 | ||||
| -rw-r--r-- | spec/factories/organisations.rb | 6 | ||||
| -rw-r--r-- | spec/factories/referentials.rb | 12 | ||||
| -rw-r--r-- | spec/factories/rule_parameter_sets.rb | 9 | ||||
| -rw-r--r-- | spec/factories/time_table_combinations.rb | 3 | ||||
| -rw-r--r-- | spec/factories/users.rb | 10 | ||||
| -rw-r--r-- | spec/factories/vehicle_translations.rb | 6 |
13 files changed, 88 insertions, 80 deletions
diff --git a/spec/factories/chouette_2_factories.rb b/spec/factories/chouette_2_factories.rb deleted file mode 100644 index a8e80702d..000000000 --- a/spec/factories/chouette_2_factories.rb +++ /dev/null @@ -1,80 +0,0 @@ -# TODO: Move these factories into their own files so all factory definitions are consistent -FactoryGirl.define do - - factory :organisation do - sequence(:name) { |n| "Organisation #{n}" } - sequence(:code) { |n| "000#{n}" } - end - - factory :referential do - sequence(:name) { |n| "Test #{n}" } - sequence(:slug) { |n| "test_#{n}" } - sequence(:prefix) { |n| "test_#{n}" } - association :organisation - association :workbench - association :line_referential - association :stop_area_referential - time_zone "Europe/Paris" - end - - factory :rule_parameter_set do - sequence(:name) { |n| "Test #{n}" } - association :organisation - after(:create) do |rsp| - rsp.parameters = RuleParameterSet.default_for_all_modes( rsp.organisation).parameters - end - end - - factory :user do - association :organisation - sequence(:name) { |n| "chouette#{n}" } - sequence(:username) { |n| "chouette#{n}" } - sequence(:email) { |n| "chouette#{n}@dryade.priv" } - password "secret" - password_confirmation "secret" - end - - factory :import_task do |f| - user_name "dummy" - user_id 123 - no_save false - format "Neptune" - resources { Rack::Test::UploadedFile.new 'spec/fixtures/neptune.zip', 'application/zip', false } - referential { Referential.find_by_slug("first") } - end - - factory :kml_export do - referential { Referential.find_by_slug("first") } - end - - factory :export do - referential { Referential.find_by_slug("first") } - end - - factory :export_log_message do - association :export - sequence(:key) { |n| "key_#{n}" } - end - - factory :vehicle_translation do - count 1 - duration 1 - end - - factory :compliance_check_result do - association :compliance_check_task - rule_code "2-NEPTUNE-StopArea-6" - severity "warning" - status "nok" - end - - factory :compliance_check_task do - user_id 1 - user_name "Dummy" - status "pending" - referential { Referential.find_by_slug("first") } - end - - factory :time_table_combination - -end diff --git a/spec/factories/compliance_check_results.rb b/spec/factories/compliance_check_results.rb new file mode 100644 index 000000000..7a3a3e956 --- /dev/null +++ b/spec/factories/compliance_check_results.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :compliance_check_result do + association :compliance_check_task + rule_code "2-NEPTUNE-StopArea-6" + severity "warning" + status "nok" + end +end diff --git a/spec/factories/compliance_check_tasks.rb b/spec/factories/compliance_check_tasks.rb new file mode 100644 index 000000000..e9fdeb5ef --- /dev/null +++ b/spec/factories/compliance_check_tasks.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :compliance_check_task do + user_id 1 + user_name "Dummy" + status "pending" + referential { Referential.find_by_slug("first") } + end +end diff --git a/spec/factories/export_log_messages.rb b/spec/factories/export_log_messages.rb new file mode 100644 index 000000000..849efd7b1 --- /dev/null +++ b/spec/factories/export_log_messages.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :export_log_message do + association :export + sequence(:key) { |n| "key_#{n}" } + end +end diff --git a/spec/factories/exports.rb b/spec/factories/exports.rb new file mode 100644 index 000000000..34427edb8 --- /dev/null +++ b/spec/factories/exports.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :export do + referential { Referential.find_by_slug("first") } + end +end diff --git a/spec/factories/import_tasks.rb b/spec/factories/import_tasks.rb new file mode 100644 index 000000000..9ca6db899 --- /dev/null +++ b/spec/factories/import_tasks.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + factory :import_task do |f| + user_name "dummy" + user_id 123 + no_save false + format "Neptune" + resources { Rack::Test::UploadedFile.new 'spec/fixtures/neptune.zip', 'application/zip', false } + referential { Referential.find_by_slug("first") } + end +end diff --git a/spec/factories/kml_exports.rb b/spec/factories/kml_exports.rb new file mode 100644 index 000000000..feb86c5b6 --- /dev/null +++ b/spec/factories/kml_exports.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :kml_export do + referential { Referential.find_by_slug("first") } + end +end diff --git a/spec/factories/organisations.rb b/spec/factories/organisations.rb new file mode 100644 index 000000000..239557a0e --- /dev/null +++ b/spec/factories/organisations.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :organisation do + sequence(:name) { |n| "Organisation #{n}" } + sequence(:code) { |n| "000#{n}" } + end +end diff --git a/spec/factories/referentials.rb b/spec/factories/referentials.rb new file mode 100644 index 000000000..dd5bf1c2e --- /dev/null +++ b/spec/factories/referentials.rb @@ -0,0 +1,12 @@ +FactoryGirl.define do + factory :referential do + sequence(:name) { |n| "Test #{n}" } + sequence(:slug) { |n| "test_#{n}" } + sequence(:prefix) { |n| "test_#{n}" } + association :organisation + association :workbench + association :line_referential + association :stop_area_referential + time_zone "Europe/Paris" + end +end diff --git a/spec/factories/rule_parameter_sets.rb b/spec/factories/rule_parameter_sets.rb new file mode 100644 index 000000000..e20fff8ce --- /dev/null +++ b/spec/factories/rule_parameter_sets.rb @@ -0,0 +1,9 @@ +FactoryGirl.define do + factory :rule_parameter_set do + sequence(:name) { |n| "Test #{n}" } + association :organisation + after(:create) do |rsp| + rsp.parameters = RuleParameterSet.default_for_all_modes( rsp.organisation).parameters + end + end +end diff --git a/spec/factories/time_table_combinations.rb b/spec/factories/time_table_combinations.rb new file mode 100644 index 000000000..364d6460e --- /dev/null +++ b/spec/factories/time_table_combinations.rb @@ -0,0 +1,3 @@ +FactoryGirl.define do + factory :time_table_combination +end diff --git a/spec/factories/users.rb b/spec/factories/users.rb new file mode 100644 index 000000000..8f0ec38c0 --- /dev/null +++ b/spec/factories/users.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + factory :user do + association :organisation + sequence(:name) { |n| "chouette#{n}" } + sequence(:username) { |n| "chouette#{n}" } + sequence(:email) { |n| "chouette#{n}@dryade.priv" } + password "secret" + password_confirmation "secret" + end +end diff --git a/spec/factories/vehicle_translations.rb b/spec/factories/vehicle_translations.rb new file mode 100644 index 000000000..1f0175222 --- /dev/null +++ b/spec/factories/vehicle_translations.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :vehicle_translation do + count 1 + duration 1 + end +end |
