Project

General

Profile

Patch #12911 ยป make_plugin_settings_path_404_for_non_configurable_plugins.patch

Harry Garrood, 2013-01-20 03:46

View differences:

app/controllers/settings_controller.rb (working copy)
52 52

  
53 53
  def plugin
54 54
    @plugin = Redmine::Plugin.find(params[:id])
55
    unless @plugin.configurable?
56
      render_404
57
      return
58
    end
59

  
55 60
    if request.post?
56 61
      Setting.send "plugin_#{@plugin.id}=", params[:settings]
57 62
      flash[:notice] = l(:notice_successful_update)
test/functional/settings_controller_test.rb (working copy)
101 101
    assert_response 404
102 102
  end
103 103

  
104
  def test_get_non_configurable_plugin_settings
105
    Redmine::Plugin.register(:foo) {}
106

  
107
    get :plugin, :id => 'foo'
108
    assert_response 404
109

  
110
    Redmine::Plugin.clear
111
  end
112

  
104 113
  def test_post_plugin_settings
105 114
    Setting.expects(:plugin_foo=).with({'sample_setting' => 'Value'}).returns(true)
106
    Redmine::Plugin.register(:foo) {}
115
    Redmine::Plugin.register(:foo) do
116
      settings :partial => 'not blank' # so that configurable? is true
117
    end
107 118

  
108 119
    post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'}
109 120
    assert_redirected_to '/settings/plugin/foo'
110 121
  end
122

  
123
  def test_post_non_configurable_plugin_settings
124
    Redmine::Plugin.register(:foo) {}
125

  
126
    post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'}
127
    assert_response 404
128

  
129
    Redmine::Plugin.clear
130
  end
111 131
end
    (1-1/1)