Commit c8179af44abaff89d99512df6017ec35a7f0c011
1 parent
0eb56fb7
Exists in
master
and in
23 other branches
ActionItem1143: fix "Edit appearance screen"
* don't display "Select themes" if there are no themes to choose from * don't display "New theme" button if user themes are disabled
Showing
2 changed files
with
50 additions
and
32 deletions
Show diff stats
app/views/themes/index.rhtml
| ... | ... | @@ -33,35 +33,37 @@ |
| 33 | 33 | <% end %> |
| 34 | 34 | |
| 35 | 35 | |
| 36 | - <tr> | |
| 37 | - <td colspan='6'> | |
| 38 | - <h2><%= _('Select theme') %></h2> | |
| 39 | - </td> | |
| 40 | - </tr> | |
| 41 | - <% for themes in @themes.in_groups_of(3) %> | |
| 36 | + <% if !@themes.empty? %> | |
| 42 | 37 | <tr> |
| 43 | - <% for theme in themes %> | |
| 44 | - <% | |
| 45 | - selected = (!theme.nil? && (theme.id == @current_theme)) | |
| 46 | - %> | |
| 47 | - <td> | |
| 48 | - <%# FIXME add proper thumbnails %> | |
| 49 | - <% if theme %> | |
| 50 | - <%= image_tag('/images/icons-app/design-editor.png', :alt => (_('The "%s" theme.') % theme.name)) %> | |
| 51 | - <% end %> | |
| 52 | - </td> | |
| 53 | - <td <%= 'class="selected theme"' if selected %>> | |
| 54 | - <% if theme %> | |
| 55 | - <strong><%= theme.name %> <%= _('(current)') if selected %></strong><br/> | |
| 56 | - <%= link_to(_('Use this theme'), :action => 'set', :id => theme.id) unless selected %> | |
| 57 | - <% end %> | |
| 58 | - </td> | |
| 59 | - <td> | |
| 60 | - | |
| 61 | - </td> | |
| 62 | - <% end %> | |
| 38 | + <td colspan='6'> | |
| 39 | + <h2><%= _('Select theme') %></h2> | |
| 40 | + </td> | |
| 63 | 41 | </tr> |
| 64 | - <tr><td colspan='3'> </td></tr> | |
| 42 | + <% for themes in @themes.in_groups_of(3) %> | |
| 43 | + <tr> | |
| 44 | + <% for theme in themes %> | |
| 45 | + <% | |
| 46 | + selected = (!theme.nil? && (theme.id == @current_theme)) | |
| 47 | + %> | |
| 48 | + <td> | |
| 49 | + <%# FIXME add proper thumbnails %> | |
| 50 | + <% if theme %> | |
| 51 | + <%= image_tag('/images/icons-app/design-editor.png', :alt => (_('The "%s" theme.') % theme.name)) %> | |
| 52 | + <% end %> | |
| 53 | + </td> | |
| 54 | + <td <%= 'class="selected theme"' if selected %>> | |
| 55 | + <% if theme %> | |
| 56 | + <strong><%= theme.name %> <%= _('(current)') if selected %></strong><br/> | |
| 57 | + <%= link_to(_('Use this theme'), :action => 'set', :id => theme.id) unless selected %> | |
| 58 | + <% end %> | |
| 59 | + </td> | |
| 60 | + <td> | |
| 61 | + | |
| 62 | + </td> | |
| 63 | + <% end %> | |
| 64 | + </tr> | |
| 65 | + <tr><td colspan='3'> </td></tr> | |
| 66 | + <% end %> | |
| 65 | 67 | <% end %> |
| 66 | 68 | |
| 67 | 69 | |
| ... | ... | @@ -96,6 +98,8 @@ |
| 96 | 98 | </table> |
| 97 | 99 | |
| 98 | 100 | <% button_bar do %> |
| 99 | - <%= lightbox_button(:add, _('New theme ...'), :action => 'new') %> | |
| 101 | + <% if environment.enabled?('user_themes') %> | |
| 102 | + <%= lightbox_button(:add, _('New theme ...'), :action => 'new') %> | |
| 103 | + <% end %> | |
| 100 | 104 | <%= button(:back, _('Back'), :controller => 'profile_editor', :action => 'index') %> |
| 101 | 105 | <% end %> | ... | ... |
test/functional/themes_controller_test.rb
| ... | ... | @@ -16,11 +16,11 @@ class ThemesControllerTest < Test::Unit::TestCase |
| 16 | 16 | @profile = create_user('testinguser').person |
| 17 | 17 | login_as('testinguser') |
| 18 | 18 | |
| 19 | - env = Environment.default | |
| 20 | - env.enable('user_themes') | |
| 21 | - env.save! | |
| 19 | + @env = Environment.default | |
| 20 | + @env.enable('user_themes') | |
| 21 | + @env.save! | |
| 22 | 22 | end |
| 23 | - attr_reader :profile | |
| 23 | + attr_reader :profile, :env | |
| 24 | 24 | |
| 25 | 25 | def teardown |
| 26 | 26 | FileUtils.rm_rf(TMP_THEMES_DIR) |
| ... | ... | @@ -258,4 +258,18 @@ class ThemesControllerTest < Test::Unit::TestCase |
| 258 | 258 | assert_redirected_to :action => 'index' |
| 259 | 259 | end |
| 260 | 260 | |
| 261 | + should 'not display "new theme" button when user themes are disabled' do | |
| 262 | + env.disable('user_themes') | |
| 263 | + env.save! | |
| 264 | + get :index, :profile => 'testinguser' | |
| 265 | + assert_no_tag :tag => 'a', :attributes => { :href => '/myprofile/testinguser/themes/new' } | |
| 266 | + end | |
| 267 | + | |
| 268 | + should 'not display the "Select themes" section if there are no themes to choose from' do | |
| 269 | + env.themes = []; env.save! | |
| 270 | + Theme.stubs(:system_themes_dir).returns(TMP_THEMES_DIR) # an empty dir | |
| 271 | + get :index, :profile => "testinguser" | |
| 272 | + assert_no_tag :content => "Select theme" | |
| 273 | + end | |
| 274 | + | |
| 261 | 275 | end | ... | ... |