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'
end
# group :test, :development do
# gem 'ruby-debug'
# end
group :test, :development do
gem 'ruby-debug'
end
# group :test do
# gem 'autotest'
# gem 'growl-glue'
# gem 'rspec-rails', '2.0.0.beta.19'
# gem 'factory_girl_rails'
# gem 'pickle', :git => 'http://github.com/ianwhite/pickle.git'
# gem 'pickle-mongoid'
# gem 'capybara'
#
# # would be nice..
# # gem 'capybara-envjs'
#
# gem 'database_cleaner'
# gem 'cucumber'
# gem 'cucumber-rails'
# gem 'spork'
# gem 'launchy'
# gem 'mocha', :git => 'git://github.com/floehopper/mocha.git'
# end
group :test do
gem 'autotest'
gem 'growl-glue'
gem 'rspec-rails', '2.0.0.beta.19'
gem 'factory_girl_rails'
gem 'pickle', :git => 'http://github.com/ianwhite/pickle.git'
gem 'pickle-mongoid'
gem 'capybara'
# would be nice..
# gem 'capybara-envjs'
gem 'database_cleaner'
gem 'cucumber'
gem 'cucumber-rails'
gem 'spork'
gem 'launchy'
gem 'mocha', :git => 'git://github.com/floehopper/mocha.git'
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
remote: git://github.com/locomotivecms/custom_fields.git
revision: 89c4d7d
@ -11,6 +18,16 @@ GIT
specs:
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
remote: /Users/didier/Desktop/NoCoffee/LocomotiveCMS/gems/carrierwave
specs:
@ -51,6 +68,7 @@ GEM
activesupport (3.0.0)
arel (1.0.1)
activesupport (~> 3.0.0)
autotest (4.4.1)
aws (2.3.21)
http_connection
uuidtools
@ -59,10 +77,30 @@ GEM
bson (1.0.4)
bson_ext (1.0.4)
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)
childprocess (0.0.7)
ffi (~> 0.6.3)
columnize (0.3.1)
configuration (1.1.0)
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)
database_cleaner (0.5.2)
delayed_job (2.1.0.pre2)
activesupport (~> 3.0)
daemons
@ -72,15 +110,26 @@ GEM
devise (1.1.2)
bcrypt-ruby (~> 2.1.2)
warden (~> 0.10.7)
diff-lcs (1.1.2)
erubis (2.6.6)
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)
ffi (0.6.3)
rake (>= 0.8.7)
formtastic-rails3 (1.0.0.beta3)
actionpack (>= 3.0.0beta3)
activesupport (>= 3.0.0beta3)
gem_plugin (0.2.3)
gemcutter (0.6.1)
gherkin (2.2.8)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
git (1.2.5)
growl-glue (1.0.7)
haml (3.0.18)
has_scope (0.5.0)
heroku (1.10.6)
@ -98,10 +147,12 @@ GEM
gemcutter (>= 0.1.0)
git (>= 1.2.5)
rubyforge (>= 2.0.0)
json (1.4.6)
json_pure (1.4.6)
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
linecache (0.43)
mail (2.2.6.1)
activesupport (>= 2.3.6)
mime-types
@ -126,6 +177,10 @@ GEM
daemons (>= 1.0.3)
fastthread (>= 1.0.1)
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)
rack (1.2.1)
rack-mount (0.6.13)
@ -150,9 +205,32 @@ GEM
rest-client (1.4.2)
mime-types (>= 1.16)
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)
json_pure (>= 1.1.7)
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)
treetop (1.4.8)
polyglot (>= 0.3.1)
@ -160,8 +238,13 @@ GEM
uuidtools (2.1.1)
warden (0.10.7)
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)
xml-simple (1.0.12)
yard (0.6.1)
PLATFORMS
ruby
@ -169,28 +252,42 @@ PLATFORMS
DEPENDENCIES
RedCloth
actionmailer-with-request
autotest
aws
bson_ext (= 1.0.4)
capybara
carrierwave!
cgi_multipart_eof_fix
cucumber
cucumber-rails
custom_fields!
database_cleaner
delayed_job (= 2.1.0.pre2)
delayed_job_mongoid (= 1.0.0.rc)
devise (= 1.1.2)
factory_girl_rails
fastthread
formtastic-rails3 (= 1.0.0.beta3)
growl-glue
haml (= 3.0.18)
heroku
httparty (= 0.6.1)
inherited_resources (= 1.1.2)
jeweler
launchy
liquid!
mimetype-fu
mocha!
mongo_session_store (= 2.0.0.pre)
mongoid (= 2.0.0.beta.17)
mongoid_acts_as_tree (= 0.1.5)
mongrel
pickle!
pickle-mongoid
rails (= 3.0.0)
rmagick (= 2.12.2)
rspec-rails (= 2.0.0.beta.19)
ruby-debug
rubyzip
spork
warden

View File

@ -21,8 +21,8 @@ class ThemeAsset
## callbacks ##
before_validation :store_plain_text
before_validation :sanitize_folder
before_validation :build_local_path
before_save :sanitize_folder
before_save :build_local_path
## validations ##
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 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)
- order yaml file (http://www.ruby-forum.com/topic/120295)
- fix tests
x order yaml file (http://www.ruby-forum.com/topic/120295)
x fix tests
- global regions: keyword in editable element (http://www.mongodb.org/display/DOCS/Updating)
- write my first tutorial about locomotive

View File

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

View File

@ -4,20 +4,47 @@ describe Locomotive::Liquid::Filters::Html do
include Locomotive::Liquid::Filters::Html
before(:each) do
@context = build_context
end
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').should == result
stylesheet_tag(nil).should == ''
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
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').should == result
javascript_tag(nil).should == ''
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
image_tag('foo.jpg').should == "<img src=\"/foo.jpg\" />"
end
@ -79,4 +106,15 @@ describe Locomotive::Liquid::Filters::Html do
html.should == ''
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

View File

@ -23,10 +23,28 @@ describe ThemeAsset do
@asset.height.should == 32
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.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
@ -64,10 +82,12 @@ describe ThemeAsset do
before(:each) do
ThemeAsset.any_instance.stubs(:site_id).returns('test')
@asset = Factory.build(:theme_asset, :site => Factory.build(:site))
@asset.performing_plain_text = true
@asset.slug = 'a file'
@asset.plain_text = "Lorem ipsum"
@asset = Factory.build(:theme_asset, {
:site => Factory.build(:site),
:plain_text_name => 'test',
:plain_text => 'Lorem ipsum',
:performing_plain_text => true
})
end
it 'should handle stylesheet' do
@ -84,24 +104,6 @@ describe ThemeAsset do
@asset.source.should_not be_nil
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