Added: branches/versions/test/fixtures/blob_versions.yml (0 => 3062)
--- branches/versions/test/fixtures/blob_versions.yml (rev 0)
+++ branches/versions/test/fixtures/blob_versions.yml 2012-07-31 14:47:00 UTC (rev 3062)
@@ -0,0 +1,74 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+picture:
+ id: 1
+ blob_id: 1
+ version: 1
+ revision_comments: some revision comment
+ local_name: file_picture.png
+ title: Picture
+ body: some text
+ created_at: 2008-04-22 15:32:01
+ content_type_id: 1
+ content_blob_id: 1
+
+text:
+ id: 2
+ blob_id: 2
+ version: 1
+ revision_comments: some revision comment
+ local_name: file_text.txt
+ title: developers.txt
+ body: myExperiment instructions
+ created_at: 2007-01-01 00:00:03
+ content_type_id: 2
+ content_blob_id: 2
+
+for_true_policy:
+ id: 3
+ blob_id: 3
+ version: 1
+ revision_comments: some revision comment
+ local_name: file_picture.png
+ title: for true policy
+ body: some text
+ created_at: 2008-04-22 15:32:01
+ content_type_id: 1
+ content_blob_id: 1
+
+for_false_policy:
+ id: 4
+ blob_id: 4
+ version: 1
+ revision_comments: some revision comment
+ local_name: file_picture.png
+ title: for false policy
+ body: some text
+ created_at: 2008-04-22 15:32:01
+ content_type_id: 1
+ content_blob_id: 1
+
+for_protected_policy:
+ id: 5
+ blob_id: 5
+ version: 1
+ revision_comments: some revision comment
+ local_name: file_picture.png
+ title: for protected policy
+ body: some text
+ created_at: 2008-04-22 15:32:01
+ content_type_id: 1
+ content_blob_id: 1
+
+for_public_policy:
+ id: 6
+ blob_id: 6
+ version: 1
+ revision_comments: some revision comment
+ local_name: file_picture.png
+ title: for public policy
+ body: some text
+ created_at: 2008-04-22 15:32:01
+ content_type_id: 1
+ content_blob_id: 1
+
Modified: branches/versions/test/fixtures/blobs.yml (3061 => 3062)
--- branches/versions/test/fixtures/blobs.yml 2012-07-31 11:53:44 UTC (rev 3061)
+++ branches/versions/test/fixtures/blobs.yml 2012-07-31 14:47:00 UTC (rev 3062)
@@ -2,6 +2,7 @@
picture:
id: 1
+ current_version: 1
contributor_id: 1
contributor_type: User
local_name: file_picture.png
@@ -14,6 +15,7 @@
text:
id: 2
+ current_version: 1
contributor_id: 2
contributor_type: User
local_name: file_text.txt
@@ -26,6 +28,7 @@
for_true_policy:
id: 3
+ current_version: 1
contributor_id: 1
contributor_type: User
local_name: file_picture.png
@@ -38,6 +41,7 @@
for_false_policy:
id: 4
+ current_version: 1
contributor_id: 1
contributor_type: User
local_name: file_picture.png
@@ -50,6 +54,7 @@
for_protected_policy:
id: 5
+ current_version: 1
contributor_id: 1
contributor_type: User
local_name: file_picture.png
@@ -62,6 +67,7 @@
for_public_policy:
id: 6
+ current_version: 1
contributor_id: 1
contributor_type: User
local_name: file_picture.png
Modified: branches/versions/test/functional/api_controller_test.rb (3061 => 3062)
--- branches/versions/test/functional/api_controller_test.rb 2012-07-31 11:53:44 UTC (rev 3061)
+++ branches/versions/test/functional/api_controller_test.rb 2012-07-31 14:47:00 UTC (rev 3062)
@@ -115,11 +115,13 @@
title = "Test file title"
title2 = "Updated test file title"
+ title3 = "Updated test file title for versions"
license_type = "by-sa"
content_type = "text/plain"
description = "A description of the test file."
- content = Base64.encode64("This is the content of this test file.")
+ content = Base64.encode64("This is the content of this test file.")
+ content2 = Base64.encode64("This is the content of this test file, version 2.")
# post a file
@@ -140,6 +142,9 @@
file = extra_files.first
+ assert_equal(file.versions.length, 1)
+ assert_equal(file.versions.first.version, 1)
+
# get the file
response = rest_request(:get, 'file', nil, "id" => file.id,
@@ -185,6 +190,37 @@
assert_equal(title2, response.find_first('/file/title').inner_xml)
assert_equal(description, response.find_first('/file/description').inner_xml)
+ # add a new version of the file
+
+ rest_request(:post, 'file', "<?xml version='1.0'?>
+ <file>
+ <title>#{title2}</title>
+ <description>#{description}</description>
+ <license-type>#{license_type}</license-type>
+ <content-type>#{content_type}</content-type>
+ <content>#{content2}</content>
+ </file>", "id" => file.id)
+
+ assert_response(:success)
+
+ file.reload
+
+ assert_equal(2, file.versions.length)
+
+ # update the first version of the file
+
+ rest_request(:put, 'file', "<?xml version='1.0'?>
+ <file>
+ <title>#{title3}</title>
+ </file>", "id" => file.id, "version" => 1)
+
+ assert_response(:success)
+
+ file.reload
+ assert_equal(title3, file.find_version(1).title);
+ assert_equal(title2, file.find_version(2).title);
+ assert_equal(title2, file.title);
+
# delete the file
rest_request(:delete, 'file', nil, "id" => file.id)