Skip to content

Commit

Permalink
[#5072] Add configuration panel
Browse files Browse the repository at this point in the history
  • Loading branch information
edavis10 committed Apr 8, 2011
1 parent 31fe6ea commit 11eac5d
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 4 deletions.
10 changes: 10 additions & 0 deletions app/views/settings/_issue_aging.html.erb
@@ -0,0 +1,10 @@
<p>
<%= content_tag(:label, l(:issue_aging_text_number_of_days_for_warning), :for => 'settings_status_warning_days') %>
<%= text_field_tag("settings[status_warning_days]", @settings['status_warning_days']) %>
</p>

<p>
<%= content_tag(:label, l(:issue_aging_text_number_of_days_for_error), :for => 'settings_status_error_days') %>
<%= text_field_tag("settings[status_error_days]", @settings['status_error_days']) %>
</p>

4 changes: 2 additions & 2 deletions config/locales/en.yml
@@ -1,3 +1,3 @@
# English strings go here for Rails i18n
en:
my_label: "My label"
issue_aging_text_number_of_days_for_warning: "Number of days before an issue enters the warning state"
issue_aging_text_number_of_days_for_error: "Number of days before an issue enters the error state"
6 changes: 6 additions & 0 deletions init.rb
Expand Up @@ -9,4 +9,10 @@
version '0.1.0'

requires_redmine :version_or_higher => '1.0.0'

settings(:partial => 'settings/issue_aging',
:default => {
'status_warning_days' => '7',
'status_error_days' => '14'
})
end
40 changes: 40 additions & 0 deletions test/integration/configuration_test.rb
@@ -0,0 +1,40 @@
require 'test_helper'

class ConfigurationTest < ActionController::IntegrationTest
def setup
@user = User.generate!(:password => 'test', :password_confirmation => 'test', :admin => true)
end

should "add a plugin configuration panel" do
login_as(@user.login, 'test')
visit_home
click_link 'Administration'
assert_response :success

click_link 'Plugins'
assert_response :success

click_link 'Configure'
assert_response :success
end

should "be able to configure the status warning days" do
login_as(@user.login, 'test')
visit_configuration_panel

fill_in "Number of days before an issue enters the warning state", :with => '30'
click_button 'Apply'

assert_equal '30', plugin_configuration['status_warning_days']
end

should "be able to configure the status error days" do
login_as(@user.login, 'test')
visit_configuration_panel

fill_in "Number of days before an issue enters the error state", :with => '90'
click_button 'Apply'

assert_equal '90', plugin_configuration['status_error_days']
end
end
30 changes: 28 additions & 2 deletions test/test_helper.rb
Expand Up @@ -14,14 +14,21 @@ def User.add_to_project(user, project, role)

module ChiliProjectIntegrationTestHelper
def login_as(user="existing", password="existing")
visit "/logout" # Make sure the session is cleared

visit "/login"
fill_in 'Login', :with => user
fill_in 'Password', :with => password
click_button 'login'
click_button 'Login'
assert_response :success
assert User.current.logged?
end

def visit_home
visit '/'
assert_response :success
end

def visit_project(project)
visit '/'
assert_response :success
Expand Down Expand Up @@ -66,11 +73,26 @@ def assert_response(code)



end

module ChiliProjectIssueAgingIntegrationTestHelper
def visit_configuration_panel
visit_home
click_link 'Administration'
assert_response :success

click_link 'Plugins'
assert_response :success

click_link 'Configure'
assert_response :success
end

end

class ActionController::IntegrationTest
include ChiliProjectIntegrationTestHelper

include ChiliProjectIssueAgingIntegrationTestHelper
include Capybara

end
Expand All @@ -90,4 +112,8 @@ def configure_plugin(configuration_change={})
def reconfigure_plugin(configuration_change)
Settings['plugin_TODO'] = Setting['plugin_TODO'].merge(configuration_change)
end

def plugin_configuration
Setting.plugin_chiliproject_issue_aging
end
end

0 comments on commit 11eac5d

Please sign in to comment.