Skip to content

Commit

Permalink
Fixed ImageFormate popup and added some tests for admin view.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed May 19, 2011
1 parent 49fd6ef commit 843743c
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 39 deletions.
8 changes: 7 additions & 1 deletion lib/zena/use/image_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ module Use
class ImageBuilder
DEFAULT_FORMATS = {
'tiny' => { :name=>'tiny', :size=>:force, :width=>16, :height=>16 , :gravity=>Magick::CenterGravity },
'tipop' => { :name=>'tipop', :size=>:force, :width=>16, :height=>16 , :gravity=>Magick::CenterGravity, :popup => 'std'},
'tipop' => { :name=>'tipop', :size=>:force, :width=>16, :height=>16 , :gravity=>Magick::CenterGravity,
:popup => {
:name => 'std',
:options => {'title' => 'link'},
:show => ['navigation','title','summary']
}
},
'mini' => { :name=>'mini', :size=>:force, :width=>32, :height=>32 , :gravity=>Magick::CenterGravity },
'square' => { :name=>'square', :size=>:limit, :width=>180, :height=>180, :gravity=>Magick::CenterGravity },
'med' => { :name=>'med', :size=>:limit, :width=>280, :height=>186, :gravity=>Magick::CenterGravity },
Expand Down
100 changes: 67 additions & 33 deletions test/functional/nodes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ class NodesControllerTest < Zena::Controller::TestCase
get_subject
assert_response :success
end

context 'with admin mode' do
subject do
{:action => 'show', :controller => 'nodes', :path => ["page#{nodes_zip(:projects)}_admin.html"], :prefix => 'en'}
end

should 'render not found' do
get_subject
assert_response :missing
end
end # with admin mode

end # visiting show

context 'with xml' do
Expand Down Expand Up @@ -460,56 +472,78 @@ class NodesControllerTest < Zena::Controller::TestCase

end # using xml

context 'using html' do
context 'destroying a node' do
context 'visiting a node' do

subject do
{:action => 'show', :controller => 'nodes', :path => ["page#{nodes_zip(:projects)}_admin.html"], :prefix => 'oo'}
end

should 'show page' do
get_subject
assert_response :success
end

context 'with admin mode' do
subject do
{:action=>'destroy', :controller=>'nodes', :id=>nodes_zip(:art)}
{:action => 'show', :controller => 'nodes', :path => ["page#{nodes_zip(:projects)}_admin.html"], :prefix => 'oo'}
end

should 'succeed' do
assert_nothing_raised do
delete_subject
end
should 'render default admin layout' do
get_subject
assert_response :success
assert_match %r{\$default/Node-admin}, @response.rendered[:template].to_s
end
end # with admin mode
end

should 'be redirected' do
delete_subject
assert_response :redirect
end
context 'destroying a node' do

# No, flash removed
# should 'be noticed that the node is destroyed' do
# delete_subject
# assert_equal 'Node destroyed.', flash[:notice]
# end
subject do
{:action=>'destroy', :controller=>'nodes', :id=>nodes_zip(:art)}
end

should 'delete the node' do
assert_difference('Node.count', -1) do
delete_subject
end
should 'succeed' do
assert_nothing_raised do
delete_subject
end
end

end # destroying a node
should 'be redirected' do
delete_subject
assert_response :redirect
end

context 'trying to destroy an inaccessible node' do
subject do
{:action=>'destroy', :controller=>'nodes', :id=>nodes_zip(:status)}
end
# No, flash removed
# should 'be noticed that the node is destroyed' do
# delete_subject
# assert_equal 'Node destroyed.', flash[:notice]
# end

should 'be noticed that it could not destroy the node' do
should 'delete the node' do
assert_difference('Node.count', -1) do
delete_subject
assert_equal "Could not destroy node.", flash[:notice]
end
end

should 'not delete the node' do
assert_difference('Node.count', 0) do
delete_subject
end
end # destroying a node

context 'trying to destroy an inaccessible node' do
subject do
{:action=>'destroy', :controller=>'nodes', :id=>nodes_zip(:status)}
end

should 'be noticed that it could not destroy the node' do
delete_subject
assert_equal "Could not destroy node.", flash[:notice]
end

should 'not delete the node' do
assert_difference('Node.count', 0) do
delete_subject
end
end

end # trying to destroy an inaccessible node
end # using html
end # trying to destroy an inaccessible node
end # A user


Expand Down
7 changes: 2 additions & 5 deletions zena.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Gaspard Bucher"]
s.date = %q{2011-05-17}
s.date = %q{2011-05-19}
s.default_executable = %q{zena}
s.description = %q{zena is a Ruby on Rails CMS (content managment system) with a focus on usability, ease of customization and web 2.0 goodness (application like behaviour).}
s.email = %q{gaspard@teti.ch}
Expand Down Expand Up @@ -444,17 +444,13 @@ Gem::Specification.new do |s|
"db/init/base/help.fr.zml",
"db/init/base/skins.zml",
"db/init/base/skins/default.zml",
"db/init/base/skins/default/Node-+adminLayout.zafu",
"db/init/base/skins/default/Node-+index.zafu",
"db/init/base/skins/default/Node-+login.zafu",
"db/init/base/skins/default/Node-+notFound.zafu",
"db/init/base/skins/default/Node-+popupLayout.zafu",
"db/init/base/skins/default/Node-+search.zafu",
"db/init/base/skins/default/Node-admin.zafu",
"db/init/base/skins/default/Node-tree.zafu",
"db/init/base/skins/default/Node.zafu",
"db/init/base/skins/default/Project.zafu",
"db/init/base/skins/default/img/admin.css",
"db/init/base/skins/default/img/favicon.png",
"db/init/base/skins/default/img/style.css",
"db/init/base/skins/default/img/translations.yml",
Expand Down Expand Up @@ -1741,6 +1737,7 @@ Gem::Specification.new do |s|
"public/javascripts/zena.js",
"public/robots.txt",
"public/stylesheets/admin.css",
"public/stylesheets/backend.css",
"public/stylesheets/calendar.css",
"public/stylesheets/code.css",
"public/stylesheets/comment.css",
Expand Down

0 comments on commit 843743c

Please sign in to comment.