forked from technoweenie/mephisto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issues previewing article drafts
git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2206 567b1171-46fb-0310-a4c9-b4bef9110e78
- Loading branch information
technoweenie
committed
Sep 18, 2006
1 parent
ca0a4b4
commit 940954d
Showing
11 changed files
with
132 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
require File.dirname(__FILE__) + '/../../test_helper' | ||
require 'admin/articles_controller' | ||
|
||
# Re-raise errors caught by the controller. | ||
class Admin::ArticlesController; def rescue_action(e) raise e end; end | ||
|
||
class Admin::ArticlesControllerAssetsTest < Test::Unit::TestCase | ||
fixtures :contents, :content_versions, :sections, :assigned_sections, :users, :sites, :tags, :taggings, :memberships | ||
|
||
def setup | ||
@controller = Admin::ArticlesController.new | ||
@request = ActionController::TestRequest.new | ||
@response = ActionController::TestResponse.new | ||
login_as :quentin | ||
FileUtils.mkdir_p ASSET_PATH | ||
end | ||
|
||
def test_should_upload_asset | ||
asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails | ||
|
||
assert_difference Asset, :count, asset_count do | ||
post :upload, :asset => { :uploaded_data => fixture_file_upload('assets/logo.png', 'image/png') } | ||
assert_response :success | ||
assert_template 'new' | ||
end | ||
end | ||
|
||
def test_should_upload_asset_and_redirect_to_article | ||
asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails | ||
|
||
assert_difference Asset, :count, asset_count do | ||
post :upload, :id => contents(:welcome).id, | ||
:asset => { :uploaded_data => fixture_file_upload('assets/logo.png', 'image/png') } | ||
assert_response :success | ||
assert_template 'edit' | ||
assert_equal contents(:welcome), assigns(:article) | ||
end | ||
end | ||
|
||
def test_should_not_error_on_new_article_asset_upload | ||
assert_no_difference Asset, :count do | ||
post :upload | ||
assert_response :success | ||
assert_template 'new' | ||
end | ||
end | ||
|
||
def test_should_not_error_on_article_asset_upload | ||
assert_no_difference Asset, :count do | ||
post :upload, :id => contents(:welcome).id | ||
assert_response :success | ||
assert_template 'edit' | ||
assert_equal contents(:welcome), assigns(:article) | ||
end | ||
end | ||
|
||
def test_should_not_create_article_when_uploading_asset | ||
Time.mock! Time.local(2005, 1, 1, 12, 0, 0) do | ||
assert_no_difference Article, :count do | ||
post :upload, :asset => { :uploaded_data => fixture_file_upload('assets/logo.png', 'image/png') }, | ||
:article => { :title => "My Red Hot Car", :excerpt => "Blah Blah", :body => "Blah Blah", | ||
'published_at(1i)' => '2005', 'published_at(2i)' => '1', 'published_at(3i)' => '1', 'published_at(4i)' => '10' }, :submit => :save | ||
assert_response :success | ||
assert_template 'new' | ||
assert_valid assigns(:article) | ||
assert assigns(:article).new_record? | ||
assert_equal Time.local(2005, 1, 1, 9, 0, 0).utc, assigns(:article).published_at | ||
assert_equal users(:quentin), assigns(:article).updater | ||
end | ||
end | ||
end | ||
|
||
def teardown | ||
FileUtils.rm_rf ASSET_PATH | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require File.dirname(__FILE__) + '/../../test_helper' | ||
require 'admin/articles_controller' | ||
|
||
# Re-raise errors caught by the controller. | ||
class Admin::ArticlesController; def rescue_action(e) raise e end; end | ||
|
||
class Admin::ArticlesControllerPreviewTest < Test::Unit::TestCase | ||
fixtures :contents, :sections, :assigned_sections, :users, :sites | ||
def setup | ||
@controller = Admin::ArticlesController.new | ||
@request = ActionController::TestRequest.new | ||
@response = ActionController::TestResponse.new | ||
login_as :quentin | ||
prepare_theme_fixtures | ||
end | ||
|
||
def test_show_action_previews_article | ||
get :show, :id => contents(:welcome).id | ||
assert_response :success | ||
end | ||
|
||
def test_show_action_previews_article_draft | ||
contents(:welcome).update_attribute :published_at, nil | ||
get :show, :id => contents(:welcome).id | ||
assert_response :success | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters