You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by al...@apache.org on 2015/08/24 13:42:13 UTC

[47/50] [abbrv] incubator-taverna-databundle-viewer git commit: Create controller_macros and include controller tests. Write controller test for data_bundle

Create controller_macros and include controller tests. Write controller test for data_bundle


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/commit/c0d65f0b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/tree/c0d65f0b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/diff/c0d65f0b

Branch: refs/heads/master
Commit: c0d65f0ba033bc4022bd320490d98e9e962397f0
Parents: d403305
Author: Denis Karyakin <sa...@gmail.com>
Authored: Thu Aug 20 16:54:38 2015 +0300
Committer: Denis Karyakin <sa...@gmail.com>
Committed: Thu Aug 20 16:54:38 2015 +0300

----------------------------------------------------------------------
 .../controllers/data_bundles_controller_spec.rb | 36 ++++++++++++++++++++
 spec/spec_helper.rb                             |  2 ++
 spec/support/controller_macros.rb               | 28 +++++++++++++++
 3 files changed, 66 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/blob/c0d65f0b/spec/controllers/data_bundles_controller_spec.rb
----------------------------------------------------------------------
diff --git a/spec/controllers/data_bundles_controller_spec.rb b/spec/controllers/data_bundles_controller_spec.rb
new file mode 100644
index 0000000..b634180
--- /dev/null
+++ b/spec/controllers/data_bundles_controller_spec.rb
@@ -0,0 +1,36 @@
+#
+# 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'
+
+RSpec.describe DataBundlesController, type: :controller do
+  login_in_controller
+  render_views
+
+  let(:json_response) { JSON.parse(response.body) }
+  let!(:data_bundle) { create :data_bundle }
+
+  it '#show' do
+    expected_result = [{'source' => 'hello', 'target' => 'Concatenate_two_strings'},
+                       {'source' => 'name', 'file_content' => 'Denis', 'target' => 'Concatenate_two_strings'},
+                       {'source' => 'Concatenate_two_strings', 'target' => 'greeting'}]
+    get :show, id: data_bundle.id, format: :json
+    expect(json_response).to match_array expected_result
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/blob/c0d65f0b/spec/spec_helper.rb
----------------------------------------------------------------------
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 9bc2b76..03aa170 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -50,6 +50,8 @@ RSpec.configure do |config|
   config.infer_base_class_for_anonymous_controllers = false
   config.order = 'random'
   config.include AbstractController::Translation
+  config.include Devise::TestHelpers, type: :controller
+  config.extend ControllerMacros, type: :controller
   config.before :suite do
     DatabaseRewinder.clean_all
   end

http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/blob/c0d65f0b/spec/support/controller_macros.rb
----------------------------------------------------------------------
diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb
new file mode 100644
index 0000000..c6e715a
--- /dev/null
+++ b/spec/support/controller_macros.rb
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+
+module ControllerMacros
+  def login_in_controller
+    before :each do
+      @request.env['devise.mapping'] = Devise.mappings[:user]
+      user = FactoryGirl.create :user
+      sign_in user
+    end
+  end
+end