diff options
author | Mark Longair <mhl@pobox.com> | 2013-10-14 19:09:25 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-10-15 10:27:37 +0100 |
commit | 944b1432fa06ba7a67f2a90c3528c95b6853120c (patch) | |
tree | 7a49412add8c1014ff0d63243dd40ba217b7f820 /spec/lib | |
parent | 48ede95299e286c03a45966b00990b544b727206 (diff) |
Make theme URL to theme name mapping consistent
The code that extracted the theme name from each entry in THEME_URLS (in
order to require code from a directory whose leaf name is the theme
name) only supported git URLs that ended in '.git'. However, the
themes:install rake task usefully supports a wider range of git URLs -
for example, all of the following were supported:
/home/whoever/themes/blah-theme => blah-theme
/home/whoever/themes/blah-theme/ => blah-theme
git://wherever/blah-theme.git => blah-theme
ssh://wherever/blah-theme.git// => blah-theme
This commit factors out a theme_url_to_theme_name method,
adds tests for it, and uses that method in both:
lib/tasks/themes.rake
config/initializers/theme_loader.rb
... so that a wider range of theme URLs are consistently supported.
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/theme_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/lib/theme_spec.rb b/spec/lib/theme_spec.rb new file mode 100644 index 000000000..829c1a269 --- /dev/null +++ b/spec/lib/theme_spec.rb @@ -0,0 +1,25 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe "theme_url_to_theme_name" do + + it "should deal with a typical bare repo URL" do + url = 'git://wherever/blah-theme.git' + theme_url_to_theme_name(url).should == 'blah-theme' + end + + it "should deal with a typical bare repo URL with trailing slashes" do + url = 'ssh://wherever/blah-theme.git//' + theme_url_to_theme_name(url).should == 'blah-theme' + end + + it "should deal with a typical non-bare repo URL" do + url = '/home/whoever/themes/blah-theme' + theme_url_to_theme_name(url).should == 'blah-theme' + end + + it "should deal with a typical non-bare repo URL with a trailing slash" do + url = '/home/whoever/themes/blah-theme/' + theme_url_to_theme_name(url).should == 'blah-theme' + end + +end |