fixing failed tests

This commit is contained in:
dinedine 2010-10-12 17:26:05 +02:00
parent 1c86db05f8
commit bab4577de0
7 changed files with 191 additions and 54 deletions

44
Gemfile
View File

@ -37,26 +37,26 @@ group :development do
gem 'fastthread' gem 'fastthread'
end end
# group :test, :development do group :test, :development do
# gem 'ruby-debug' gem 'ruby-debug'
# end end
# group :test do group :test do
# gem 'autotest' gem 'autotest'
# gem 'growl-glue' gem 'growl-glue'
# gem 'rspec-rails', '2.0.0.beta.19' gem 'rspec-rails', '2.0.0.beta.19'
# gem 'factory_girl_rails' gem 'factory_girl_rails'
# gem 'pickle', :git => 'http://github.com/ianwhite/pickle.git' gem 'pickle', :git => 'http://github.com/ianwhite/pickle.git'
# gem 'pickle-mongoid' gem 'pickle-mongoid'
# gem 'capybara' gem 'capybara'
#
# # would be nice.. # would be nice..
# # gem 'capybara-envjs' # gem 'capybara-envjs'
#
# gem 'database_cleaner' gem 'database_cleaner'
# gem 'cucumber' gem 'cucumber'
# gem 'cucumber-rails' gem 'cucumber-rails'
# gem 'spork' gem 'spork'
# gem 'launchy' gem 'launchy'
# gem 'mocha', :git => 'git://github.com/floehopper/mocha.git' gem 'mocha', :git => 'git://github.com/floehopper/mocha.git'
# end end

View File

@ -1,3 +1,10 @@
GIT
remote: git://github.com/floehopper/mocha.git
revision: e0a00a7b2adf8f11d3679879df9a5c47a5c36189
specs:
mocha (0.9.8.20100819090654)
rake
GIT GIT
remote: git://github.com/locomotivecms/custom_fields.git remote: git://github.com/locomotivecms/custom_fields.git
revision: 89c4d7d revision: 89c4d7d
@ -11,6 +18,16 @@ GIT
specs: specs:
liquid (2.1.3) liquid (2.1.3)
GIT
remote: http://github.com/ianwhite/pickle.git
revision: 65ba8b7337f38d0ab4c153b3ab687e13de7086c7
specs:
pickle (0.4.2)
cucumber (>= 0.8)
rake
rspec (>= 1.3)
yard
PATH PATH
remote: /Users/didier/Desktop/NoCoffee/LocomotiveCMS/gems/carrierwave remote: /Users/didier/Desktop/NoCoffee/LocomotiveCMS/gems/carrierwave
specs: specs:
@ -51,6 +68,7 @@ GEM
activesupport (3.0.0) activesupport (3.0.0)
arel (1.0.1) arel (1.0.1)
activesupport (~> 3.0.0) activesupport (~> 3.0.0)
autotest (4.4.1)
aws (2.3.21) aws (2.3.21)
http_connection http_connection
uuidtools uuidtools
@ -59,10 +77,30 @@ GEM
bson (1.0.4) bson (1.0.4)
bson_ext (1.0.4) bson_ext (1.0.4)
builder (2.1.2) builder (2.1.2)
capybara (0.3.9)
culerity (>= 0.2.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.3)
cgi_multipart_eof_fix (2.5.0) cgi_multipart_eof_fix (2.5.0)
childprocess (0.0.7)
ffi (~> 0.6.3)
columnize (0.3.1)
configuration (1.1.0) configuration (1.1.0)
crack (0.1.8) crack (0.1.8)
cucumber (0.9.2)
builder (~> 2.1.2)
diff-lcs (~> 1.1.2)
gherkin (~> 2.2.5)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
cucumber-rails (0.3.2)
cucumber (>= 0.8.0)
culerity (0.2.12)
daemons (1.1.0) daemons (1.1.0)
database_cleaner (0.5.2)
delayed_job (2.1.0.pre2) delayed_job (2.1.0.pre2)
activesupport (~> 3.0) activesupport (~> 3.0)
daemons daemons
@ -72,15 +110,26 @@ GEM
devise (1.1.2) devise (1.1.2)
bcrypt-ruby (~> 2.1.2) bcrypt-ruby (~> 2.1.2)
warden (~> 0.10.7) warden (~> 0.10.7)
diff-lcs (1.1.2)
erubis (2.6.6) erubis (2.6.6)
abstract (>= 1.0.0) abstract (>= 1.0.0)
factory_girl (1.3.2)
factory_girl_rails (1.0)
factory_girl (~> 1.3)
rails (>= 3.0.0.beta4)
fastthread (1.0.7) fastthread (1.0.7)
ffi (0.6.3)
rake (>= 0.8.7)
formtastic-rails3 (1.0.0.beta3) formtastic-rails3 (1.0.0.beta3)
actionpack (>= 3.0.0beta3) actionpack (>= 3.0.0beta3)
activesupport (>= 3.0.0beta3) activesupport (>= 3.0.0beta3)
gem_plugin (0.2.3) gem_plugin (0.2.3)
gemcutter (0.6.1) gemcutter (0.6.1)
gherkin (2.2.8)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
git (1.2.5) git (1.2.5)
growl-glue (1.0.7)
haml (3.0.18) haml (3.0.18)
has_scope (0.5.0) has_scope (0.5.0)
heroku (1.10.6) heroku (1.10.6)
@ -98,10 +147,12 @@ GEM
gemcutter (>= 0.1.0) gemcutter (>= 0.1.0)
git (>= 1.2.5) git (>= 1.2.5)
rubyforge (>= 2.0.0) rubyforge (>= 2.0.0)
json (1.4.6)
json_pure (1.4.6) json_pure (1.4.6)
launchy (0.3.7) launchy (0.3.7)
configuration (>= 0.0.5) configuration (>= 0.0.5)
rake (>= 0.8.1) rake (>= 0.8.1)
linecache (0.43)
mail (2.2.6.1) mail (2.2.6.1)
activesupport (>= 2.3.6) activesupport (>= 2.3.6)
mime-types mime-types
@ -126,6 +177,10 @@ GEM
daemons (>= 1.0.3) daemons (>= 1.0.3)
fastthread (>= 1.0.1) fastthread (>= 1.0.1)
gem_plugin (>= 0.2.3) gem_plugin (>= 0.2.3)
nokogiri (1.4.3.1)
pickle-mongoid (0.1.6)
mongoid (>= 2.0.0.beta.7)
pickle (>= 0.3.0)
polyglot (0.3.1) polyglot (0.3.1)
rack (1.2.1) rack (1.2.1)
rack-mount (0.6.13) rack-mount (0.6.13)
@ -150,9 +205,32 @@ GEM
rest-client (1.4.2) rest-client (1.4.2)
mime-types (>= 1.16) mime-types (>= 1.16)
rmagick (2.12.2) rmagick (2.12.2)
rspec (2.0.0.beta.19)
rspec-core (= 2.0.0.beta.19)
rspec-expectations (= 2.0.0.beta.19)
rspec-mocks (= 2.0.0.beta.19)
rspec-core (2.0.0.beta.19)
rspec-expectations (2.0.0.beta.19)
diff-lcs (>= 1.1.2)
rspec-mocks (2.0.0.beta.19)
rspec-rails (2.0.0.beta.19)
rspec (= 2.0.0.beta.19)
webrat (>= 0.7.2.beta.1)
ruby-debug (0.10.3)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.3.0)
ruby-debug-base (0.10.3)
linecache (>= 0.3)
rubyforge (2.0.4) rubyforge (2.0.4)
json_pure (>= 1.1.7) json_pure (>= 1.1.7)
rubyzip (0.9.4) rubyzip (0.9.4)
selenium-webdriver (0.0.29)
childprocess (>= 0.0.7)
ffi (~> 0.6.3)
json_pure
rubyzip
spork (0.8.4)
term-ansicolor (1.0.5)
thor (0.14.2) thor (0.14.2)
treetop (1.4.8) treetop (1.4.8)
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
@ -160,8 +238,13 @@ GEM
uuidtools (2.1.1) uuidtools (2.1.1)
warden (0.10.7) warden (0.10.7)
rack (>= 1.0.0) rack (>= 1.0.0)
webrat (0.7.2.beta.2)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
will_paginate (3.0.pre2) will_paginate (3.0.pre2)
xml-simple (1.0.12) xml-simple (1.0.12)
yard (0.6.1)
PLATFORMS PLATFORMS
ruby ruby
@ -169,28 +252,42 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
RedCloth RedCloth
actionmailer-with-request actionmailer-with-request
autotest
aws aws
bson_ext (= 1.0.4) bson_ext (= 1.0.4)
capybara
carrierwave! carrierwave!
cgi_multipart_eof_fix cgi_multipart_eof_fix
cucumber
cucumber-rails
custom_fields! custom_fields!
database_cleaner
delayed_job (= 2.1.0.pre2) delayed_job (= 2.1.0.pre2)
delayed_job_mongoid (= 1.0.0.rc) delayed_job_mongoid (= 1.0.0.rc)
devise (= 1.1.2) devise (= 1.1.2)
factory_girl_rails
fastthread fastthread
formtastic-rails3 (= 1.0.0.beta3) formtastic-rails3 (= 1.0.0.beta3)
growl-glue
haml (= 3.0.18) haml (= 3.0.18)
heroku heroku
httparty (= 0.6.1) httparty (= 0.6.1)
inherited_resources (= 1.1.2) inherited_resources (= 1.1.2)
jeweler jeweler
launchy
liquid! liquid!
mimetype-fu mimetype-fu
mocha!
mongo_session_store (= 2.0.0.pre) mongo_session_store (= 2.0.0.pre)
mongoid (= 2.0.0.beta.17) mongoid (= 2.0.0.beta.17)
mongoid_acts_as_tree (= 0.1.5) mongoid_acts_as_tree (= 0.1.5)
mongrel mongrel
pickle!
pickle-mongoid
rails (= 3.0.0) rails (= 3.0.0)
rmagick (= 2.12.2) rmagick (= 2.12.2)
rspec-rails (= 2.0.0.beta.19)
ruby-debug
rubyzip rubyzip
spork
warden warden

View File

@ -21,8 +21,8 @@ class ThemeAsset
## callbacks ## ## callbacks ##
before_validation :store_plain_text before_validation :store_plain_text
before_validation :sanitize_folder before_save :sanitize_folder
before_validation :build_local_path before_save :build_local_path
## validations ## ## validations ##
validates_presence_of :site, :source validates_presence_of :site, :source

View File

@ -40,8 +40,8 @@ x refactor ui for the theme assets page
x fix assets liquid tags / filters x fix assets liquid tags / filters
x upload and insert new images in a css or js from the ui is broken x upload and insert new images in a css or js from the ui is broken
x proxy for fonts (http://markevans.github.com/dragonfly/file.Rails3.html) x proxy for fonts (http://markevans.github.com/dragonfly/file.Rails3.html)
- order yaml file (http://www.ruby-forum.com/topic/120295) x order yaml file (http://www.ruby-forum.com/topic/120295)
- fix tests x fix tests
- global regions: keyword in editable element (http://www.mongodb.org/display/DOCS/Updating) - global regions: keyword in editable element (http://www.mongodb.org/display/DOCS/Updating)
- write my first tutorial about locomotive - write my first tutorial about locomotive

View File

@ -24,10 +24,10 @@ describe Locomotive::Liquid::Drops::Contents do
def render_template(template = '', assigns = {}) def render_template(template = '', assigns = {})
assigns = { assigns = {
'contents' => Locomotive::Liquid::Drops::Contents.new(@site) 'contents' => Locomotive::Liquid::Drops::Contents.new
}.merge(assigns) }.merge(assigns)
Liquid::Template.parse(template).render assigns Liquid::Template.parse(template).render(::Liquid::Context.new({}, assigns, { :site => @site }))
end end
end end

View File

@ -4,20 +4,47 @@ describe Locomotive::Liquid::Filters::Html do
include Locomotive::Liquid::Filters::Html include Locomotive::Liquid::Filters::Html
before(:each) do
@context = build_context
end
it 'should return a link tag for a stylesheet file' do it 'should return a link tag for a stylesheet file' do
result = "<link href=\"main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />" result = "<link href=\"/sites/42/theme/stylesheets/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
stylesheet_tag('main.css').should == result stylesheet_tag('main.css').should == result
stylesheet_tag('main').should == result stylesheet_tag('main').should == result
stylesheet_tag(nil).should == '' stylesheet_tag(nil).should == ''
end end
it 'should return a link tag for a stylesheet file with folder' do
result = "<link href=\"/sites/42/theme/stylesheets/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
stylesheet_tag('trash/main.css').should == result
end
it 'should return a link tag for a stylesheet file without touching the url' do
result = "<link href=\"/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
stylesheet_tag('/trash/main.css').should == result
stylesheet_tag('/trash/main').should == result
end
it 'should return a script tag for a javascript file' do it 'should return a script tag for a javascript file' do
result = %{<script src="main.js" type="text/javascript"></script>} result = %{<script src="/sites/42/theme/javascripts/main.js" type="text/javascript"></script>}
javascript_tag('main.js').should == result javascript_tag('main.js').should == result
javascript_tag('main').should == result javascript_tag('main').should == result
javascript_tag(nil).should == '' javascript_tag(nil).should == ''
end end
it 'should return a script tag for a javascript file with folder' do
result = %{<script src="/sites/42/theme/javascripts/trash/main.js" type="text/javascript"></script>}
javascript_tag('trash/main.js').should == result
javascript_tag('trash/main').should == result
end
it 'should return a script tag for a javascript file without touching the url' do
result = %{<script src="/trash/main.js" type="text/javascript"></script>}
javascript_tag('/trash/main.js').should == result
javascript_tag('/trash/main').should == result
end
it 'should return an image tag without paramaters' do it 'should return an image tag without paramaters' do
image_tag('foo.jpg').should == "<img src=\"/foo.jpg\" />" image_tag('foo.jpg').should == "<img src=\"/foo.jpg\" />"
end end
@ -79,4 +106,15 @@ describe Locomotive::Liquid::Filters::Html do
html.should == '' html.should == ''
end end
def build_context
Site.any_instance.stubs(:id).returns(42)
klass = Class.new
klass.class_eval do
def registers
{ :site => Factory.build(:site) }
end
end
klass.new
end
end end

View File

@ -23,10 +23,28 @@ describe ThemeAsset do
@asset.height.should == 32 @asset.height.should == 32
end end
it 'should have a slug' do end
describe 'local path and folder' do
it 'should set the local path based on the content type' do
@asset.source = FixturedAsset.open('5k.png') @asset.source = FixturedAsset.open('5k.png')
@asset.save @asset.save
@asset.slug.should == '5k' @asset.local_path.should == 'images/5k.png'
end
it 'should set the local path based on the folder' do
@asset.folder = 'trash'
@asset.source = FixturedAsset.open('5k.png')
@asset.save
@asset.local_path.should == 'images/trash/5k.png'
end
it 'should set sanitize the local path' do
@asset.folder = '/images/à la poubelle'
@asset.source = FixturedAsset.open('5k.png')
@asset.save
@asset.local_path.should == 'images/a_la_poubelle/5k.png'
end end
end end
@ -64,10 +82,12 @@ describe ThemeAsset do
before(:each) do before(:each) do
ThemeAsset.any_instance.stubs(:site_id).returns('test') ThemeAsset.any_instance.stubs(:site_id).returns('test')
@asset = Factory.build(:theme_asset, :site => Factory.build(:site)) @asset = Factory.build(:theme_asset, {
@asset.performing_plain_text = true :site => Factory.build(:site),
@asset.slug = 'a file' :plain_text_name => 'test',
@asset.plain_text = "Lorem ipsum" :plain_text => 'Lorem ipsum',
:performing_plain_text => true
})
end end
it 'should handle stylesheet' do it 'should handle stylesheet' do
@ -84,24 +104,6 @@ describe ThemeAsset do
@asset.source.should_not be_nil @asset.source.should_not be_nil
end end
context 'shortcut urls' do
before(:each) do
@image = Factory.build(:theme_asset, :source => FixturedAsset.open('5k.png'))
@image.source.stubs(:url).returns('5k.png')
@asset.stubs(:stylesheet?).returns(true)
@asset.site.theme_assets.stubs(:where).returns([@image])
@asset.plain_text = 'body { background-image: url("/theme/images/5k.png"); } h1 { background-image: url("/images/5k.png"); }'
@asset.store_plain_text
end
it 'replaces shortcut url if present' do
@asset.plain_text.should == 'body { background-image: url("/theme/images/5k.png"); } h1 { background-image: url("/images/5k.png"); }'
@asset.source.read.should == 'body { background-image: url("5k.png"); } h1 { background-image: url("/images/5k.png"); }'
end
end
end end
end end