Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reverting multiple blocks still doesn't work.

* Added tests to confirm its not working.
  • Loading branch information...
commit 6c65853d65136cab31df51762aacff27f12fc40f 1 parent e0b55a4
@peakpg peakpg authored
View
9 test/factories/attachables.rb
@@ -50,6 +50,15 @@ class HasManyAttachments < ActiveRecord::Base
m.publish_on_save true
end
+ factory :has_many_documents, :class => Cms::Attachment do |m|
+ m.attachment_name "documents"
+ m.attachable_type "HasManyAttachments"
+ m.data { mock_file }
+ m.parent { find_or_create_root_section }
+ m.attachable_version 1
+ m.publish_on_save true
+ end
+
factory :attachment_document, :class => Cms::Attachment do |m|
m.attachment_name "document"
m.attachable_type "VersionedAttachable"
View
27 test/unit/behaviors/attaching_test.rb
@@ -419,7 +419,7 @@ def setup
test "delete an attachment should not be found when fetching the draft version of blocks" do
@attachable.attachments.first.destroy
- update_to_version2(@attachable)
+ update_to_version(@attachable)
current = @attachable.as_of_draft_version()
assert_equal 0, current.attachments.size
@@ -428,19 +428,36 @@ def setup
test "deleted attachments should be found when looking up historical versions" do
@attachable.attachments.first.destroy
- update_to_version2(@attachable)
+ update_to_version(@attachable)
assert_equal 0, @attachable.as_of_version(2).attachments.size
assert_equal 1, @attachable.as_of_version(1).attachments.size
end
+ test "reverting with multiple attachments doesn't work correctly'" do
+ @attachable = create(:has_many_attachments)
+
+ @attachable.attachments.first.destroy
+ update_to_version(@attachable, 2)
+ @attachable.attachments << create(:has_many_documents, :data_file_name => "new.txt", :attachable_version => 2)
+ update_to_version(@attachable, 3)
+
+ assert_equal "new.txt", @attachable.attachments.first.data_file_name
+
+ @attachable.revert_to(1)
+ @attachable.reload
+
+ assert_equal 1, @attachable.attachments.size
+ assert_equal "new.txt", @attachable.attachments.first.data_file_name, "If this worked properly, it roll back to version 1 of the attachment."
+
+ end
private
- def update_to_version2(attachable)
- attachable.update_attributes(:name => "v2")
+ def update_to_version(attachable, v=2)
+ attachable.update_attributes(:name => "v#{v}")
attachable.publish!
attachable.reload
- assert_equal 2, attachable.version, "Verifying that we have actually force this block to version 2"
+ assert_equal v, attachable.version, "Verifying that we have actually force this block to version #{v}"
end
def update_attachable_to_version2(new_path)
View
4 todo_list.markdown
@@ -3,8 +3,6 @@ Tasks:
* Paperclip Based Assets - Replace the existing 'custom' file upload behavior with one that uses Paperclip. Allow blocks to have more than one attachment.
- [Documentation] Write a quick how to guide about Attachments API.
-- [BUG] If you revert a block with multiple attachments, it will still be associated with the latest attachments.
-- [BUG] Minor - In development mode, need to restart if core CMS code is changed (loses definations for custom blocks with attachments)
- [IMPROVE] The error message for a duplicate path for Fileblocks is not clear.
@@ -30,6 +28,8 @@ When almost certainly should be.
- [TEST] Upgrade script from 3.4.x and 3.3.x
- [BUG] Updating a page throws 'path already used' error? Created a public section.
+- [BUG] Reverting blocks with multiple attachments doesn't really work. It stays associated with the latest attachment, even if you had previous deleted attachments.
+- [BUG] Minor - In development mode, need to restart if core CMS code is changed (loses definations for custom blocks with attachments)
# 3.4.x
Please sign in to comment.
Something went wrong with that request. Please try again.