Skip to content

Commit

Permalink
Fixed proper querystring handling. Thanks Felix.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabien committed Oct 7, 2008
1 parent b325107 commit 936cf4b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
10 changes: 5 additions & 5 deletions merb-assets/lib/merb-assets/assets_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def image_tag(img, opts={})
opts[:src] ||= opts.delete(:path) + img
end
random = opts.delete(:reload) || Merb::Config[:reload_templates]
opts[:src] += random_query_string if random
opts[:src] += opts[:src].include?('?') ? "&#{random_query_string}" : "?#{random_query_string}" if random
%{<img #{ opts.to_xml_attributes } />}
end

Expand Down Expand Up @@ -442,7 +442,7 @@ def js_include_tag(*scripts)

for script in scripts
src = asset_path(:javascript, script)
src += random_query_string if reload
src += src.include?('?') ? "&#{random_query_string}" : "?#{random_query_string}" if reload
attrs = {
:src => src,
:type => "text/javascript"
Expand Down Expand Up @@ -504,7 +504,7 @@ def css_include_tag(*stylesheets)

for stylesheet in stylesheets
href = asset_path(:stylesheet, stylesheet)
href += random_query_string if reload
href += href.include?('?') ? "&#{random_query_string}" : "?#{random_query_string}" if reload
attrs = {
:href => href,
:type => "text/css",
Expand Down Expand Up @@ -642,8 +642,8 @@ def extract_required_files(files, options = {})
end

def random_query_string
Time.now.strftime("?%m%d%H%M%S#{rand(99)}")
Time.now.strftime("%m%d%H%M%S#{rand(99)}")
end

end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ end

<% if testing_framework.to_sym == :rspec %>
require 'spec/rake/spectask'
require "merb-core/test/tasks/spectasks"
require 'merb-core/test/tasks/spectasks'
desc 'Default: run spec examples'
task :default => 'spec'
<% end %>
Expand Down
3 changes: 3 additions & 0 deletions merb-slices/lib/generators/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class SliceGenerator < Generator

class BaseSliceGenerator < NamedGenerator

option :testing_framework, :default => :rspec,
:desc => 'Testing framework to use (one of: rspec, test_unit).'

def self.common_template(name, template_source)
common_base_dir = File.expand_path(File.dirname(__FILE__))
template name do |t|
Expand Down
13 changes: 12 additions & 1 deletion merb-slices/lib/generators/templates/common/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,15 @@ task :gemspec do
File.open("#{GEM_NAME}.gemspec", "w") do |file|
file.puts spec.to_ruby
end
end
end

<% if testing_framework.to_sym == :rspec %>
require 'spec/rake/spectask'
require 'merb-core/test/tasks/spectasks'
desc 'Default: run spec examples'
task :default => 'spec'
<% end %>
<% if testing_framework.to_sym == :test_unit %>
require 'rake/testtask'
<% end %>
24 changes: 9 additions & 15 deletions merb-slices/lib/generators/templates/full/Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
require 'rubygems'
require 'rake/gempackagetask'
require 'spec/rake/spectask'

require 'merb-core'
require 'merb-core/tasks/merb'
require 'merb-core/test/tasks/spectasks'

GEM_NAME = "<%= base_name %>"
AUTHOR = "Your Name"
Expand Down Expand Up @@ -51,17 +49,13 @@ task :gemspec do
end
end

desc "Run all examples (or a specific spec with TASK=xxxx)"
Spec::Rake::SpecTask.new('spec') do |t|
t.spec_opts = ["-cfs"]
t.spec_files = begin
if ENV["TASK"]
ENV["TASK"].split(',').map { |task| "spec/**/#{task}_spec.rb" }
else
FileList['spec/**/*_spec.rb']
end
end
end

<% if testing_framework.to_sym == :rspec %>
require 'spec/rake/spectask'
require 'merb-core/test/tasks/spectasks'
desc 'Default: run spec examples'
task :default => 'spec'
task :default => 'spec'
<% end %>
<% if testing_framework.to_sym == :test_unit %>
require 'rake/testtask'
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
controller.slice_url(:index, :format => 'html').should == url

url = controller.url(:<%= symbol_name %>_home)
url.should == "/<%= base_name %>"
url.should == "/<%= base_name %>/"
controller.slice_url(:home).should == url
end

Expand Down

0 comments on commit 936cf4b

Please sign in to comment.