Diff
Modified: branches/datasets/app/controllers/data_items_controller.rb (2859 => 2860)
--- branches/datasets/app/controllers/data_items_controller.rb 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/app/controllers/data_items_controller.rb 2011-12-02 16:34:49 UTC (rev 2860)
@@ -178,7 +178,7 @@
def fetch_port_names
port_type = params[:port_type] || @data_item.objekt.port_type.to_s
- existing_ports = @data_set.relationships.select do |r|
+ existing_ports = @data_set.data_items.select do |r|
port_type == "input" && r.objekt.input? ||
port_type == "output" && r.objekt.output?
end.collect {|r| r.objekt.name}
Modified: branches/datasets/app/controllers/data_sets_controller.rb (2859 => 2860)
--- branches/datasets/app/controllers/data_sets_controller.rb 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/app/controllers/data_sets_controller.rb 2011-12-02 16:34:49 UTC (rev 2860)
@@ -84,7 +84,13 @@
def fetch_workflow
@workflow = @data_set ? @data_set.workflow : Workflow.find(params[:workflow_id])
- unless DataSet::SUPPORTED_TYPES.include?(@workflow.type)
+ if @workflow.nil?
+ flash[:error] = "Workflow not found"
+
+ respond_to do |format|
+ format.html { redirect_to workflows_url}
+ end
+ elsif !DataSet::SUPPORTED_TYPES.include?(@workflow.type)
flash[:error] = "Data sets are not yet supported for address@hidden workflows."
respond_to do |format|
@@ -104,7 +110,6 @@
# You can view data sets if you can download the workflow
# You can create new data sets if you can edit the workflow
def auth
- puts action_name
if action_name == "index"
unless Authorization.is_authorized?("download", nil, @workflow, current_user)
flash[:error] = "You are not authorized to this workflow's data sets."
Modified: branches/datasets/app/models/data_set.rb (2859 => 2860)
--- branches/datasets/app/models/data_set.rb 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/app/models/data_set.rb 2011-12-02 16:34:49 UTC (rev 2860)
@@ -43,7 +43,7 @@
# the port it relates to, followed by a dash, followed by either the name of the file if it is a blob,
# or "text.txt" if it is just text data.
- relationships.each do |data_item|
+ data_items.each do |data_item|
data = ""
port = data_item.objekt
Modified: branches/datasets/app/views/data_sets/_data_item_form.rhtml (2859 => 2860)
--- branches/datasets/app/views/data_sets/_data_item_form.rhtml 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/app/views/data_sets/_data_item_form.rhtml 2011-12-02 16:34:49 UTC (rev 2860)
@@ -71,8 +71,8 @@
:loading => "$('relationship_form_spinner_#{unique_id}').show();",
:complete => "$('relationship_form_spinner_#{unique_id}').hide();" do %>
<%# todo: fix this %>
- <%= hidden_field_tag :predicate_id, port_type == "input" ? Predicate.find_by_title("exampleInputDataTo").id :
- Predicate.find_by_title("exampleOutputDataFrom").id %>
+ <%= hidden_field_tag :predicate_id, port_type == "input" ? Predicate.find_by_title("inputDataTo").id :
+ Predicate.find_by_title("outputDataFrom").id %>
<div id="data_item_form_errors" style="display:none"></div>
Modified: branches/datasets/test/fixtures/content_types.yml (2859 => 2860)
--- branches/datasets/test/fixtures/content_types.yml 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/test/fixtures/content_types.yml 2011-12-02 16:34:49 UTC (rev 2860)
@@ -34,8 +34,6 @@
taverna2:
user_id: 1
title: Taverna 2
- description: The Taverna 2 workflow file format.
- description_html: "<p>The Taverna 2 workflow file format.</p>"
mime_type: application/vnd.taverna.t2flow+xml
created_at: 2008-04-22 15:32:01
updated_at: 2008-04-22 15:32:01
Modified: branches/datasets/test/fixtures/contributions.yml (2859 => 2860)
--- branches/datasets/test/fixtures/contributions.yml 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/test/fixtures/contributions.yml 2011-12-02 16:34:49 UTC (rev 2860)
@@ -119,3 +119,14 @@
downloads_count: 1
viewings_count: 1
+contribution_workflow_string_concat:
+ contributor_id: 1 # John
+ contributor_type: User
+ contributable: string_concat (Workflow)
+ policy: only_john_can_edit
+
+contribution_data_set_string_concat_v1_example:
+ contributor_id: 1 # John
+ contributor_type: User
+ contributable: string_concat_v1_example (DataSet)
+ policy: only_john_can_edit
\ No newline at end of file
Modified: branches/datasets/test/fixtures/data_sets.yml (2859 => 2860)
--- branches/datasets/test/fixtures/data_sets.yml 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/test/fixtures/data_sets.yml 2011-12-02 16:34:49 UTC (rev 2860)
@@ -0,0 +1,6 @@
+string_concat_v1_example:
+ workflow: string_concat
+ workflow_version: 1
+ category: example_data
+ contributor_id: 1 # John
+ contributor_type: User
\ No newline at end of file
Modified: branches/datasets/test/fixtures/policies.yml (2859 => 2860)
--- branches/datasets/test/fixtures/policies.yml 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/test/fixtures/policies.yml 2011-12-02 16:34:49 UTC (rev 2860)
@@ -59,3 +59,9 @@
created_at: 2007-10-22 18:54:22
updated_at: 2008-01-09 12:12:12
+only_john_can_edit:
+ contributor_id: 1 #John
+ contributor_type: User
+ name: Anyone can view and download, only John can edit
+ share_mode: 0
+ update_mode: 6
Modified: branches/datasets/test/fixtures/predicates.yml (2859 => 2860)
--- branches/datasets/test/fixtures/predicates.yml 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/test/fixtures/predicates.yml 2011-12-02 16:34:49 UTC (rev 2860)
@@ -1,4 +1,3 @@
-
test_predicate_1:
id: 1
title: Test predicate
@@ -10,4 +9,12 @@
created_at: 2008-02-14 20:19:18
updated_at: 2008-02-14 20:19:18
+input_data_to:
+ title: inputDataTo
+ phrase: is input data to
+ ontology_id: 1
+output_data_from:
+ title: outputDataFrom
+ phrase: is output data from
+ ontology_id: 1
\ No newline at end of file
Added: branches/datasets/test/fixtures/relationships.yml (0 => 2860)
--- branches/datasets/test/fixtures/relationships.yml (rev 0)
+++ branches/datasets/test/fixtures/relationships.yml 2011-12-02 16:34:49 UTC (rev 2860)
@@ -0,0 +1,23 @@
+# For data set: string_concat_v1_example
+string_concat_v1_example_text_data:
+ subject: string1_example (TextData)
+ objekt: string_concat_v1_string1 (WorkflowPort)
+ predicate: input_data_to
+ context: string_concat_v1_example (DataSet)
+ user_id: 1 # john
+
+string_concat_v1_example_file_data:
+ subject_id: 1 # picture
+ subject_type: Blob
+ objekt: string_concat_v1_string2 (WorkflowPort)
+ predicate: input_data_to
+ context: string_concat_v1_example (DataSet)
+ user_id: 1 # john
+
+string_concat_v1_example_text_data2:
+ subject: result_example (TextData)
+ objekt: string_concat_v1_result (WorkflowPort)
+ predicate: output_data_from
+ context: string_concat_v1_example (DataSet)
+ user_id: 1 # john
+
Added: branches/datasets/test/fixtures/text_data.yml (0 => 2860)
--- branches/datasets/test/fixtures/text_data.yml (rev 0)
+++ branches/datasets/test/fixtures/text_data.yml 2011-12-02 16:34:49 UTC (rev 2860)
@@ -0,0 +1,7 @@
+string1_example:
+ data: hello
+ data_set: string_concat_v1_example
+
+result_example:
+ data: hello world
+ data_set: string_concat_v1_example
\ No newline at end of file
Modified: branches/datasets/test/fixtures/workflow_ports.yml (2859 => 2860)
--- branches/datasets/test/fixtures/workflow_ports.yml 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/test/fixtures/workflow_ports.yml 2011-12-02 16:34:49 UTC (rev 2860)
@@ -0,0 +1,22 @@
+string_concat_v1_string1:
+ workflow: string_concat
+ workflow_version: 1
+ port_type: input
+ name: string1
+
+string_concat_v1_string2:
+ workflow: string_concat
+ workflow_version: 1
+ port_type: input
+ name: string2
+
+string_concat_v1_result:
+ workflow: string_concat
+ workflow_version: 1
+ port_type: output
+ name: result
+
+string_concat_v2_string1:
+ workflow: string_concat
+ workflow_version: 1
+ port_type: input
\ No newline at end of file
Modified: branches/datasets/test/fixtures/workflows.yml (2859 => 2860)
--- branches/datasets/test/fixtures/workflows.yml 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/test/fixtures/workflows.yml 2011-12-02 16:34:49 UTC (rev 2860)
@@ -28,7 +28,8 @@
content_blob_id: 4
string_concat:
- contributor: john (User)
+ contributor_id: 1 # John
+ contributor_type: User
title: Concatenate Three Strings
unique_name: string_concat
content_blob: string_concat_v2
Modified: branches/datasets/test/functional/data_sets_controller_test.rb (2859 => 2860)
--- branches/datasets/test/functional/data_sets_controller_test.rb 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/test/functional/data_sets_controller_test.rb 2011-12-02 16:34:49 UTC (rev 2860)
@@ -0,0 +1,76 @@
+# myExperiment: test/functional/data_sets_controller_test.rb
+#
+# Copyright (c) 2011University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class DataSetsControllerTest < ActionController::TestCase
+
+ test "can create data sets" do
+ workflow = workflows(:string_concat)
+
+ login_as(:john)
+
+ assert_difference("DataSet.count", 1) do
+ post :create, :workflow_id => workflow.id,
+ :data_set => {
+ :title => "new data set",
+ :workflow_version => 1,
+ :category => "example_data"
+ }
+ end
+
+ assert_redirected_to data_set_path(assigns(:data_set))
+ end
+
+ test "can't create data sets if not authorized" do
+ workflow = workflows(:string_concat)
+
+ login_as(:jane)
+
+ assert_no_difference("DataSet.count") do
+ post :create, :workflow_id => workflow.id,
+ :data_set => {
+ :title => "new data set",
+ :workflow_version => 1,
+ :category => "example_data"
+ }
+ end
+
+ assert flash[:error]
+ assert_redirected_to workflow_data_sets_path(workflow)
+ end
+
+ test "can't destroy data sets if not authorized" do
+ data_set = data_sets(:string_concat_v1_example)
+
+ login_as(:jane)
+
+ assert_no_difference("DataSet.count") do
+ delete :destroy, :id => data_set.id
+ end
+
+ assert flash[:error]
+ assert_redirected_to data_set_url(data_set)
+ end
+
+ test "can destroy data set without leaving orphaned resources" do
+ data_set = data_sets(:string_concat_v1_example)
+ item_count = data_set.data_items.size
+ text_data_count = data_set.data_items.select {|i| i.subject_type == "TextData"}.size
+
+ login_as(:john)
+
+ assert_difference("TextData.count", -text_data_count) do
+ assert_difference("Relationship.count", -item_count) do
+ assert_difference("DataSet.count", -1) do
+ delete :destroy, :id => data_set.id
+ end
+ end
+ end
+
+ assert_redirected_to workflow_data_sets_url(data_set.workflow)
+ end
+
+end
Modified: branches/datasets/test/unit/data_set_test.rb (2859 => 2860)
--- branches/datasets/test/unit/data_set_test.rb 2011-12-02 13:40:16 UTC (rev 2859)
+++ branches/datasets/test/unit/data_set_test.rb 2011-12-02 16:34:49 UTC (rev 2860)
@@ -1,14 +1,15 @@
require File.dirname(__FILE__) + '/../test_helper'
+require 'digest/md5'
class DataSetTest < ActiveSupport::TestCase
- fixtures :workflows
- fixtures :blobs
- fixtures :workflow_ports
- fixtures :data_sets
- fixtures :text_data
- # Replace this with your real tests.
- def test_truth
- assert true
+ # Uses MD5 checksum to determine zipping was successful - maybe too fragile?
+ test "can create a zip file" do
+ data_set = data_sets(:string_concat_v1_example)
+ zip_data = data_set.create_zip(users(:john)).string
+
+ assert_equal("fcb670d73a2c7798576974a1c4f61b5c", Digest::MD5.hexdigest(zip_data))
end
+
+
end