Updated tests, add hello_anyone as a fixture for testing
diff --git a/spec/decorators/data_bundle_decorator_spec.rb b/spec/decorators/data_bundle_decorator_spec.rb
index 7430da3..3bd1e88 100644
--- a/spec/decorators/data_bundle_decorator_spec.rb
+++ b/spec/decorators/data_bundle_decorator_spec.rb
@@ -1,3 +1,22 @@
+#
+# 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.
+#
+
require 'spec_helper'
describe DataBundleDecorator do
diff --git a/spec/factories/data_bundles.rb b/spec/factories/data_bundles.rb
index d27e2fd..74d5f1e 100644
--- a/spec/factories/data_bundles.rb
+++ b/spec/factories/data_bundles.rb
@@ -21,5 +21,6 @@
factory :data_bundle do
association :user
name { Faker::Lorem.sentence }
+ file { Rack::Test::UploadedFile.new("#{Rails.root}/spec/fixtures/hello_anyone.zip") }
end
end
diff --git a/spec/feature/data_bundles_spec.rb b/spec/feature/data_bundles_spec.rb
index 7f687b3..52d6ac2 100644
--- a/spec/feature/data_bundles_spec.rb
+++ b/spec/feature/data_bundles_spec.rb
@@ -34,6 +34,7 @@
name = Faker::Lorem.sentence
expect {
fill_in 'data_bundle_name', with: name
+ attach_file 'data_bundle_file', "#{Rails.root}/spec/fixtures/hello_anyone.zip"
click_button 'save_data_bundle'
}.to change(DataBundle, :count).by(1)
visit data_bundles_path
@@ -48,10 +49,28 @@
expect(page).not_to have_content data_bundle_foreign.name
end
- xit 'show databundle' do
- visit data_bundle_path(data_bundle)
+ it 'show databundle' do
+ click_link "to_show_#{data_bundle.id}"
expect(page).to have_content data_bundle.name
end
+
+ it 'edit databundle' do
+ click_link "to_edit_#{data_bundle.id}"
+ new_name = Faker::Lorem.sentence
+ expect {
+ fill_in 'data_bundle_name', with: new_name
+ click_button 'save_data_bundle'
+ }.not_to change(DataBundle, :count)
+ expect(page).to have_content new_name
+ end
+
+ it 'delete databundle', js: true do
+ expect {
+ page.accept_confirm do
+ click_link "to_delete_#{data_bundle.id}"
+ end
+ }.to change(DataBundle, :count).by(-1)
+ end
end
context 'anonymous user' do
diff --git a/spec/fixtures/hello_anyone.zip b/spec/fixtures/hello_anyone.zip
new file mode 100644
index 0000000..8a99a1e
--- /dev/null
+++ b/spec/fixtures/hello_anyone.zip
Binary files differ
diff --git a/spec/models/data_bundle_spec.rb b/spec/models/data_bundle_spec.rb
index 245ad4d..56706df 100644
--- a/spec/models/data_bundle_spec.rb
+++ b/spec/models/data_bundle_spec.rb
@@ -27,4 +27,8 @@
it 'without user - invalid' do
expect(build(:data_bundle, user: nil)).not_to be_valid
end
+
+ it 'without file - invalid' do
+ expect(build(:data_bundle, file: nil)).not_to be_valid
+ end
end