Commit d3284d42bd5e2dcac61de961f43cb0a7ea739720
1 parent
a46ca8c8
Exists in
master
and in
29 other branches
rails3: fix folder tests
PS: still failing test because xss_terminate is stripping html comments now.
Showing
1 changed file
with
8 additions
and
8 deletions
Show diff stats
test/unit/folder_test.rb
... | ... | @@ -31,8 +31,8 @@ class FolderTest < ActiveSupport::TestCase |
31 | 31 | should 'have images that are only images or other folders' do |
32 | 32 | p = create_user('test_user').person |
33 | 33 | f = fast_create(Folder, :profile_id => p.id) |
34 | - file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain'), :parent => f, :profile => p) | |
35 | - image = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => f, :profile => p) | |
34 | + file = create(UploadedFile, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain'), :parent => f, :profile => p) | |
35 | + image = create(UploadedFile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => f, :profile => p) | |
36 | 36 | folder = fast_create(Folder, :profile_id => p.id, :parent_id => f.id) |
37 | 37 | |
38 | 38 | assert_equivalent [folder, image], f.images |
... | ... | @@ -42,7 +42,7 @@ class FolderTest < ActiveSupport::TestCase |
42 | 42 | p = create_user('test_user').person |
43 | 43 | f = fast_create(Folder, :profile_id => p.id) |
44 | 44 | folder1 = fast_create(Folder, :name => 'b', :profile_id => p.id, :parent_id => f.id) |
45 | - image = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => f, :profile => p) | |
45 | + image = create(UploadedFile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => f, :profile => p) | |
46 | 46 | folder2 = fast_create(Folder, :name => 'c', :profile_id => p.id, :parent_id => f.id) |
47 | 47 | folder3 = fast_create(Folder, :name => 'a', :profile_id => p.id, :parent_id => f.id) |
48 | 48 | |
... | ... | @@ -53,7 +53,7 @@ class FolderTest < ActiveSupport::TestCase |
53 | 53 | p = create_user('test_user').person |
54 | 54 | f = fast_create(Folder, :profile_id => p.id) |
55 | 55 | folder = fast_create(Folder, :profile_id => p.id, :parent_id => f.id) |
56 | - image = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => f, :profile => p) | |
56 | + image = create(UploadedFile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => f, :profile => p) | |
57 | 57 | |
58 | 58 | assert_equal [image], f.images.paginate(:page => 2, :per_page => 1) |
59 | 59 | end |
... | ... | @@ -62,7 +62,7 @@ class FolderTest < ActiveSupport::TestCase |
62 | 62 | c = fast_create(Community) |
63 | 63 | folder = fast_create(Folder, :profile_id => c.id) |
64 | 64 | f = fast_create(Folder, :name => 'folder', :profile_id => c.id, :parent_id => folder.id) |
65 | - u = UploadedFile.create!(:profile => c, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => folder) | |
65 | + u = create(UploadedFile, :profile => c, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => folder) | |
66 | 66 | older_t = fast_create(TinyMceArticle, :name => 'old news', :profile_id => c.id, :parent_id => folder.id) |
67 | 67 | t = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id, :parent_id => folder.id) |
68 | 68 | t_in_f = fast_create(TinyMceArticle, :name => 'news', :profile_id => c.id, :parent_id => f.id) |
... | ... | @@ -90,11 +90,11 @@ class FolderTest < ActiveSupport::TestCase |
90 | 90 | |
91 | 91 | should 'return published images as images' do |
92 | 92 | person = create_user('test_user').person |
93 | - image = UploadedFile.create!(:profile => person, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | |
93 | + image = create(UploadedFile, :profile => person, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | |
94 | 94 | |
95 | 95 | community = fast_create(Community) |
96 | 96 | folder = fast_create(Folder, :profile_id => community.id) |
97 | - a = ApproveArticle.create!(:article => image, :target => community, :requestor => person, :article_parent => folder) | |
97 | + a = create(ApproveArticle, :article => image, :target => community, :requestor => person, :article_parent => folder) | |
98 | 98 | a.finish |
99 | 99 | |
100 | 100 | assert_includes folder.images(true), community.articles.find_by_name('rails.png') |
... | ... | @@ -137,7 +137,7 @@ class FolderTest < ActiveSupport::TestCase |
137 | 137 | folder.parent = Blog.new |
138 | 138 | folder.valid? |
139 | 139 | |
140 | - assert folder.errors.on(:parent) | |
140 | + assert folder.errors[:parent].present? | |
141 | 141 | end |
142 | 142 | |
143 | 143 | should 'accept uploads' do | ... | ... |