diff options
| author | Xinhui | 2016-12-28 12:14:19 +0100 |
|---|---|---|
| committer | Xinhui | 2016-12-28 13:00:47 +0100 |
| commit | 15e221c2fe06ebd6ca18d7a392ab05f95b59be74 (patch) | |
| tree | 130db86de564b4aff40b9df8ee61119dd54263ef /spec | |
| parent | b6129f04b5f9b5a4c325c43d1a13b0e9b7d48647 (diff) | |
| download | chouette-core-15e221c2fe06ebd6ca18d7a392ab05f95b59be74.tar.bz2 | |
Model ImportMessage ImportResource
Refs #2261
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/imports_controller_spec.rb | 4 | ||||
| -rw-r--r-- | spec/factories/import_messages.rb | 10 | ||||
| -rw-r--r-- | spec/factories/import_resources.rb | 6 | ||||
| -rw-r--r-- | spec/factories/imports.rb | 12 | ||||
| -rw-r--r-- | spec/models/import_message_spec.rb | 7 | ||||
| -rw-r--r-- | spec/models/import_resource_spec.rb | 13 | ||||
| -rw-r--r-- | spec/models/import_spec.rb | 1 |
7 files changed, 46 insertions, 7 deletions
diff --git a/spec/controllers/imports_controller_spec.rb b/spec/controllers/imports_controller_spec.rb index f5ccd643a..19756b72f 100644 --- a/spec/controllers/imports_controller_spec.rb +++ b/spec/controllers/imports_controller_spec.rb @@ -3,9 +3,11 @@ require 'rails_helper' RSpec.describe ImportsController, :type => :controller do login_user + let(:workbench) { create :workbench } + describe 'GET #new' do it 'should be successful' do - get :new, referential_id: referential.id + get :new, workbench_id: workbench.id expect(response).to be_success end end diff --git a/spec/factories/import_messages.rb b/spec/factories/import_messages.rb new file mode 100644 index 000000000..2d26477e6 --- /dev/null +++ b/spec/factories/import_messages.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + factory :import_message do + criticity 1 +message_key "MyString" +message_attributs "" +import nil +resource nil + end + +end diff --git a/spec/factories/import_resources.rb b/spec/factories/import_resources.rb new file mode 100644 index 000000000..274edab60 --- /dev/null +++ b/spec/factories/import_resources.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :import_resource do + association :import + status :new + end +end diff --git a/spec/factories/imports.rb b/spec/factories/imports.rb index 8b2cb223d..bb9a97c9c 100644 --- a/spec/factories/imports.rb +++ b/spec/factories/imports.rb @@ -1,11 +1,11 @@ FactoryGirl.define do factory :import do + name "MyString" + current_step_id "MyString" + current_step_progress 1.5 + association :workbench + association :referential + file {File.open(File.join(Rails.root, 'spec', 'fixtures', 'terminated_job.json'))} status "MyString" -current_step_id "MyString" -current_step_progress 1.5 -workbench nil -referential nil -name "MyString" end - end diff --git a/spec/models/import_message_spec.rb b/spec/models/import_message_spec.rb new file mode 100644 index 000000000..2d8aac2b7 --- /dev/null +++ b/spec/models/import_message_spec.rb @@ -0,0 +1,7 @@ +require 'rails_helper' + +RSpec.describe ImportMessage, :type => :model do + it { should validate_presence_of(:criticity) } + it { should belong_to(:import) } + it { should belong_to(:resource) } +end diff --git a/spec/models/import_resource_spec.rb b/spec/models/import_resource_spec.rb new file mode 100644 index 000000000..a2177979e --- /dev/null +++ b/spec/models/import_resource_spec.rb @@ -0,0 +1,13 @@ +require 'rails_helper' + +RSpec.describe ImportResource, :type => :model do + it { should belong_to(:import) } + + describe 'states' do + let(:import_resource) { create(:import_resource) } + + it 'should initialize with new state' do + expect(import_resource.new?).to be_truthy + end + end +end diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index 10a508c71..4c44eb99c 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -3,5 +3,6 @@ require 'rails_helper' RSpec.describe Import, :type => :model do it { should belong_to(:referential) } it { should belong_to(:workbench) } + it { should validate_presence_of(:file) } end |
