diff --git a/app/views/themes/index.rhtml b/app/views/themes/index.rhtml
index a63c598..671bc88 100644
--- a/app/views/themes/index.rhtml
+++ b/app/views/themes/index.rhtml
@@ -33,35 +33,37 @@
<% end %>
-
-
- <%= _('Select theme') %>
- |
-
- <% for themes in @themes.in_groups_of(3) %>
+ <% if !@themes.empty? %>
- <% for theme in themes %>
- <%
- selected = (!theme.nil? && (theme.id == @current_theme))
- %>
-
- <%# FIXME add proper thumbnails %>
- <% if theme %>
- <%= image_tag('/images/icons-app/design-editor.png', :alt => (_('The "%s" theme.') % theme.name)) %>
- <% end %>
- |
- >
- <% if theme %>
- <%= theme.name %> <%= _('(current)') if selected %>
- <%= link_to(_('Use this theme'), :action => 'set', :id => theme.id) unless selected %>
- <% end %>
- |
-
-
- |
- <% end %>
+
+ <%= _('Select theme') %>
+ |
- |
+ <% for themes in @themes.in_groups_of(3) %>
+
+ <% for theme in themes %>
+ <%
+ selected = (!theme.nil? && (theme.id == @current_theme))
+ %>
+
+ <%# FIXME add proper thumbnails %>
+ <% if theme %>
+ <%= image_tag('/images/icons-app/design-editor.png', :alt => (_('The "%s" theme.') % theme.name)) %>
+ <% end %>
+ |
+ >
+ <% if theme %>
+ <%= theme.name %> <%= _('(current)') if selected %>
+ <%= link_to(_('Use this theme'), :action => 'set', :id => theme.id) unless selected %>
+ <% end %>
+ |
+
+
+ |
+ <% end %>
+
+ |
+ <% end %>
<% end %>
@@ -96,6 +98,8 @@
<% button_bar do %>
- <%= lightbox_button(:add, _('New theme ...'), :action => 'new') %>
+ <% if environment.enabled?('user_themes') %>
+ <%= lightbox_button(:add, _('New theme ...'), :action => 'new') %>
+ <% end %>
<%= button(:back, _('Back'), :controller => 'profile_editor', :action => 'index') %>
<% end %>
diff --git a/test/functional/themes_controller_test.rb b/test/functional/themes_controller_test.rb
index 43637e1..ed6ac6d 100644
--- a/test/functional/themes_controller_test.rb
+++ b/test/functional/themes_controller_test.rb
@@ -16,11 +16,11 @@ class ThemesControllerTest < Test::Unit::TestCase
@profile = create_user('testinguser').person
login_as('testinguser')
- env = Environment.default
- env.enable('user_themes')
- env.save!
+ @env = Environment.default
+ @env.enable('user_themes')
+ @env.save!
end
- attr_reader :profile
+ attr_reader :profile, :env
def teardown
FileUtils.rm_rf(TMP_THEMES_DIR)
@@ -258,4 +258,18 @@ class ThemesControllerTest < Test::Unit::TestCase
assert_redirected_to :action => 'index'
end
+ should 'not display "new theme" button when user themes are disabled' do
+ env.disable('user_themes')
+ env.save!
+ get :index, :profile => 'testinguser'
+ assert_no_tag :tag => 'a', :attributes => { :href => '/myprofile/testinguser/themes/new' }
+ end
+
+ should 'not display the "Select themes" section if there are no themes to choose from' do
+ env.themes = []; env.save!
+ Theme.stubs(:system_themes_dir).returns(TMP_THEMES_DIR) # an empty dir
+ get :index, :profile => "testinguser"
+ assert_no_tag :content => "Select theme"
+ end
+
end
--
libgit2 0.21.2