summaryrefslogtreecommitdiffstats
path: root/test/unit/project_test.rb
diff options
context:
space:
mode:
authorJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2011-06-19 23:45:22 +0000
committerJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2011-06-19 23:45:22 +0000
commit88bd76b0e49485fd0f34decb51ea2f0d6c8a129c (patch)
treef799ddad190464b45be6a5069534643a38eb7747 /test/unit/project_test.rb
parent8022c66b0862dcf1170b5a0fdc8953490d27b50c (diff)
downloadredmine-88bd76b0e49485fd0f34decb51ea2f0d6c8a129c.tar.gz
redmine-88bd76b0e49485fd0f34decb51ea2f0d6c8a129c.zip
Added Project#enable_module! and Project#disable_module! (#7115)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6098 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/project_test.rb')
-rw-r--r--test/unit/project_test.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index d307500e3..1fe6f1506 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -597,6 +597,54 @@ class ProjectTest < ActiveSupport::TestCase
end
end
+ context "enabled_modules" do
+ setup do
+ @project = Project.find(1)
+ end
+
+ should "define module by names and preserve ids" do
+ # Remove one module
+ modules = @project.enabled_modules.slice(0..-2)
+ assert modules.any?
+ assert_difference 'EnabledModule.count', -1 do
+ @project.enabled_module_names = modules.collect(&:name)
+ end
+ @project.reload
+ # Ids should be preserved
+ assert_equal @project.enabled_module_ids.sort, modules.collect(&:id).sort
+ end
+
+ should "enable a module" do
+ @project.enabled_module_names = []
+ @project.reload
+ assert_equal [], @project.enabled_module_names
+ #with string
+ @project.enable_module!("issue_tracking")
+ assert_equal ["issue_tracking"], @project.enabled_module_names
+ #with symbol
+ @project.enable_module!(:gantt)
+ assert_equal ["issue_tracking", "gantt"], @project.enabled_module_names
+ #don't add a module twice
+ @project.enable_module!("issue_tracking")
+ assert_equal ["issue_tracking", "gantt"], @project.enabled_module_names
+ end
+
+ should "disable a module" do
+ #with string
+ assert @project.enabled_module_names.include?("issue_tracking")
+ @project.disable_module!("issue_tracking")
+ assert ! @project.reload.enabled_module_names.include?("issue_tracking")
+ #with symbol
+ assert @project.enabled_module_names.include?("gantt")
+ @project.disable_module!(:gantt)
+ assert ! @project.reload.enabled_module_names.include?("gantt")
+ #with EnabledModule object
+ first_module = @project.enabled_modules.first
+ @project.disable_module!(first_module)
+ assert ! @project.reload.enabled_module_names.include?(first_module.name)
+ end
+ end
+
def test_enabled_module_names_should_not_recreate_enabled_modules
project = Project.find(1)
# Remove one module