diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-10-10 21:42:24 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-10-10 21:42:24 +0000 |
commit | 700c302fca1ef401eff2744ffc5d955406136b17 (patch) | |
tree | 971c3a59e56ba799c8ba61d546705a90d2d51347 /test/unit/project_test.rb | |
parent | d2986eb98fa4ec163cf09c82a36fff3ca8f5f48b (diff) | |
download | redmine-700c302fca1ef401eff2744ffc5d955406136b17.tar.gz redmine-700c302fca1ef401eff2744ffc5d955406136b17.zip |
Change Project#notified_users to check for the 'all' notification option. #6541
The previous mail_notification? check would always pass since the
notifications where converted to strings and strings are always true.
Also changed Project#recipients to use #notified_users instead of duplicated
code.
Based on contribution by Felix Schäfer.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4247 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/project_test.rb')
-rw-r--r-- | test/unit/project_test.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index 9b8809c2b..08b0fb24a 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -964,4 +964,54 @@ class ProjectTest < ActiveSupport::TestCase end end + + context "#notified_users" do + setup do + @project = Project.generate! + @role = Role.generate! + + @user_with_membership_notification = User.generate!(:mail_notification => 'selected') + Member.generate!(:project => @project, :roles => [@role], :principal => @user_with_membership_notification, :mail_notification => true) + + @all_events_user = User.generate!(:mail_notification => 'all') + Member.generate!(:project => @project, :roles => [@role], :principal => @all_events_user) + + @no_events_user = User.generate!(:mail_notification => 'none') + Member.generate!(:project => @project, :roles => [@role], :principal => @no_events_user) + + @only_my_events_user = User.generate!(:mail_notification => 'only_my_events') + Member.generate!(:project => @project, :roles => [@role], :principal => @only_my_events_user) + + @only_assigned_user = User.generate!(:mail_notification => 'only_assigned') + Member.generate!(:project => @project, :roles => [@role], :principal => @only_assigned_user) + + @only_owned_user = User.generate!(:mail_notification => 'only_owner') + Member.generate!(:project => @project, :roles => [@role], :principal => @only_owned_user) + end + + should "include members with a mail notification" do + assert @project.notified_users.include?(@user_with_membership_notification) + end + + should "include users with the 'all' notification option" do + assert @project.notified_users.include?(@all_events_user) + end + + should "not include users with the 'none' notification option" do + assert !@project.notified_users.include?(@no_events_user) + end + + should "not include users with the 'only_my_events' notification option" do + assert !@project.notified_users.include?(@only_my_events_user) + end + + should "not include users with the 'only_assigned' notification option" do + assert !@project.notified_users.include?(@only_assigned_user) + end + + should "not include users with the 'only_owner' notification option" do + assert !@project.notified_users.include?(@only_owned_user) + end + end + end |