Code cleanup: implement Plugin#to_param for generating routes.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10995 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
c93fccc84a
commit
c31f498ba6
|
@ -55,7 +55,7 @@ class SettingsController < ApplicationController
|
||||||
if request.post?
|
if request.post?
|
||||||
Setting.send "plugin_#{@plugin.id}=", params[:settings]
|
Setting.send "plugin_#{@plugin.id}=", params[:settings]
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to plugin_settings_path(@plugin.id)
|
redirect_to plugin_settings_path(@plugin)
|
||||||
else
|
else
|
||||||
@partial = @plugin.settings[:partial]
|
@partial = @plugin.settings[:partial]
|
||||||
@settings = Setting.send "plugin_#{@plugin.id}"
|
@settings = Setting.send "plugin_#{@plugin.id}"
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
<% if @plugins.any? %>
|
<% if @plugins.any? %>
|
||||||
<table class="list plugins">
|
<table class="list plugins">
|
||||||
<% @plugins.each do |plugin| %>
|
<% @plugins.each do |plugin| %>
|
||||||
<tr class="<%= cycle('odd', 'even') %>">
|
<tr id="plugin-<%= plugin.id %>" class="<%= cycle('odd', 'even') %>">
|
||||||
<td><span class="name"><%=h plugin.name %></span>
|
<td><span class="name"><%=h plugin.name %></span>
|
||||||
<%= content_tag('span', h(plugin.description), :class => 'description') unless plugin.description.blank? %>
|
<%= content_tag('span', h(plugin.description), :class => 'description') unless plugin.description.blank? %>
|
||||||
<%= content_tag('span', link_to(h(plugin.url), plugin.url), :class => 'url') unless plugin.url.blank? %>
|
<%= content_tag('span', link_to(h(plugin.url), plugin.url), :class => 'url') unless plugin.url.blank? %>
|
||||||
</td>
|
</td>
|
||||||
<td class="author"><%= plugin.author_url.blank? ? h(plugin.author) : link_to(h(plugin.author), plugin.author_url) %></td>
|
<td class="author"><%= plugin.author_url.blank? ? h(plugin.author) : link_to(h(plugin.author), plugin.author_url) %></td>
|
||||||
<td class="version"><%=h plugin.version %></td>
|
<td class="version"><%=h plugin.version %></td>
|
||||||
<td class="configure"><%= link_to(l(:button_configure), :controller => 'settings', :action => 'plugin', :id => plugin.id) if plugin.configurable? %></td>
|
<td class="configure"><%= link_to(l(:button_configure), plugin_settings_path(plugin)) if plugin.configurable? %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -145,6 +145,10 @@ module Redmine #:nodoc:
|
||||||
File.join(self.class.public_directory, id.to_s)
|
File.join(self.class.public_directory, id.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_param
|
||||||
|
id
|
||||||
|
end
|
||||||
|
|
||||||
def assets_directory
|
def assets_directory
|
||||||
File.join(directory, 'assets')
|
File.join(directory, 'assets')
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,15 +27,13 @@ class AdminControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_index
|
def test_index
|
||||||
get :index
|
get :index
|
||||||
assert_no_tag :tag => 'div',
|
assert_select 'div.nodata', 0
|
||||||
:attributes => { :class => /nodata/ }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_no_configuration_data
|
def test_index_with_no_configuration_data
|
||||||
delete_configuration_data
|
delete_configuration_data
|
||||||
get :index
|
get :index
|
||||||
assert_tag :tag => 'div',
|
assert_select 'div.nodata'
|
||||||
:attributes => { :class => /nodata/ }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_projects
|
def test_projects
|
||||||
|
@ -128,8 +126,14 @@ class AdminControllerTest < ActionController::TestCase
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'plugins'
|
assert_template 'plugins'
|
||||||
|
|
||||||
assert_tag :td, :child => { :tag => 'span', :content => 'Foo plugin' }
|
assert_select 'tr#plugin-foo' do
|
||||||
assert_tag :td, :child => { :tag => 'span', :content => 'Bar' }
|
assert_select 'td span.name', :text => 'Foo plugin'
|
||||||
|
assert_select 'td.configure a[href=/settings/plugin/foo]'
|
||||||
|
end
|
||||||
|
assert_select 'tr#plugin-bar' do
|
||||||
|
assert_select 'td span.name', :text => 'Bar'
|
||||||
|
assert_select 'td.configure a', 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_info
|
def test_info
|
||||||
|
@ -145,8 +149,7 @@ class AdminControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
get :index
|
get :index
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_tag :a, :attributes => { :href => '/foo/bar' },
|
assert_select 'div#admin-menu a[href=/foo/bar]', :text => 'Test'
|
||||||
:content => 'Test'
|
|
||||||
|
|
||||||
Redmine::MenuManager.map :admin_menu do |menu|
|
Redmine::MenuManager.map :admin_menu do |menu|
|
||||||
menu.delete :test_admin_menu_plugin_extension
|
menu.delete :test_admin_menu_plugin_extension
|
||||||
|
|
Loading…
Reference in New Issue