Mercurial > hg > soundsoftware-site
comparison test/unit/project_test.rb @ 37:94944d00e43c
* Update to SVN trunk rev 4411
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 19 Nov 2010 13:24:41 +0000 |
parents | 40f7cfd4df19 |
children | af80e5618e9b |
comparison
equal
deleted
inserted
replaced
22:40f7cfd4df19 | 37:94944d00e43c |
---|---|
27 end | 27 end |
28 | 28 |
29 should_validate_presence_of :name | 29 should_validate_presence_of :name |
30 should_validate_presence_of :identifier | 30 should_validate_presence_of :identifier |
31 | 31 |
32 should_validate_uniqueness_of :name | |
33 should_validate_uniqueness_of :identifier | 32 should_validate_uniqueness_of :identifier |
34 | 33 |
35 context "associations" do | 34 context "associations" do |
36 should_have_many :members | 35 should_have_many :members |
37 should_have_many :users, :through => :members | 36 should_have_many :users, :through => :members |
100 user = @ecookbook.members.first.user | 99 user = @ecookbook.members.first.user |
101 @ecookbook.archive | 100 @ecookbook.archive |
102 @ecookbook.reload | 101 @ecookbook.reload |
103 | 102 |
104 assert !@ecookbook.active? | 103 assert !@ecookbook.active? |
104 assert @ecookbook.archived? | |
105 assert !user.projects.include?(@ecookbook) | 105 assert !user.projects.include?(@ecookbook) |
106 # Subproject are also archived | 106 # Subproject are also archived |
107 assert !@ecookbook.children.empty? | 107 assert !@ecookbook.children.empty? |
108 assert @ecookbook.descendants.active.empty? | 108 assert @ecookbook.descendants.active.empty? |
109 end | 109 end |
127 | 127 |
128 # Unarchive project | 128 # Unarchive project |
129 assert @ecookbook.unarchive | 129 assert @ecookbook.unarchive |
130 @ecookbook.reload | 130 @ecookbook.reload |
131 assert @ecookbook.active? | 131 assert @ecookbook.active? |
132 assert !@ecookbook.archived? | |
132 assert user.projects.include?(@ecookbook) | 133 assert user.projects.include?(@ecookbook) |
133 # Subproject can now be unarchived | 134 # Subproject can now be unarchived |
134 @ecookbook_sub1.reload | 135 @ecookbook_sub1.reload |
135 assert @ecookbook_sub1.unarchive | 136 assert @ecookbook_sub1.unarchive |
136 end | 137 end |
858 @project.enabled_modules.find_all_by_name('issue_tracking').each {|m| m.destroy} | 859 @project.enabled_modules.find_all_by_name('issue_tracking').each {|m| m.destroy} |
859 @project.reload | 860 @project.reload |
860 | 861 |
861 assert_nil @project.start_date | 862 assert_nil @project.start_date |
862 end | 863 end |
864 | |
865 should "be tested when issues have no start date" | |
863 | 866 |
864 should "be the earliest start date of it's issues" do | 867 should "be the earliest start date of it's issues" do |
865 early = 7.days.ago.to_date | 868 early = 7.days.ago.to_date |
866 Issue.generate_for_project!(@project, :start_date => Date.today) | 869 Issue.generate_for_project!(@project, :start_date => Date.today) |
867 Issue.generate_for_project!(@project, :start_date => early) | 870 Issue.generate_for_project!(@project, :start_date => early) |
887 @project.enabled_modules.find_all_by_name('issue_tracking').each {|m| m.destroy} | 890 @project.enabled_modules.find_all_by_name('issue_tracking').each {|m| m.destroy} |
888 @project.reload | 891 @project.reload |
889 | 892 |
890 assert_nil @project.due_date | 893 assert_nil @project.due_date |
891 end | 894 end |
895 | |
896 should "be tested when issues have no due date" | |
892 | 897 |
893 should "be the latest due date of it's issues" do | 898 should "be the latest due date of it's issues" do |
894 future = 7.days.from_now.to_date | 899 future = 7.days.from_now.to_date |
895 Issue.generate_for_project!(@project, :due_date => future) | 900 Issue.generate_for_project!(@project, :due_date => future) |
896 Issue.generate_for_project!(@project, :due_date => Date.today) | 901 Issue.generate_for_project!(@project, :due_date => Date.today) |
958 assert_equal 50, @project.completed_percent | 963 assert_equal 50, @project.completed_percent |
959 end | 964 end |
960 | 965 |
961 end | 966 end |
962 end | 967 end |
968 | |
969 context "#notified_users" do | |
970 setup do | |
971 @project = Project.generate! | |
972 @role = Role.generate! | |
973 | |
974 @user_with_membership_notification = User.generate!(:mail_notification => 'selected') | |
975 Member.generate!(:project => @project, :roles => [@role], :principal => @user_with_membership_notification, :mail_notification => true) | |
976 | |
977 @all_events_user = User.generate!(:mail_notification => 'all') | |
978 Member.generate!(:project => @project, :roles => [@role], :principal => @all_events_user) | |
979 | |
980 @no_events_user = User.generate!(:mail_notification => 'none') | |
981 Member.generate!(:project => @project, :roles => [@role], :principal => @no_events_user) | |
982 | |
983 @only_my_events_user = User.generate!(:mail_notification => 'only_my_events') | |
984 Member.generate!(:project => @project, :roles => [@role], :principal => @only_my_events_user) | |
985 | |
986 @only_assigned_user = User.generate!(:mail_notification => 'only_assigned') | |
987 Member.generate!(:project => @project, :roles => [@role], :principal => @only_assigned_user) | |
988 | |
989 @only_owned_user = User.generate!(:mail_notification => 'only_owner') | |
990 Member.generate!(:project => @project, :roles => [@role], :principal => @only_owned_user) | |
991 end | |
992 | |
993 should "include members with a mail notification" do | |
994 assert @project.notified_users.include?(@user_with_membership_notification) | |
995 end | |
996 | |
997 should "include users with the 'all' notification option" do | |
998 assert @project.notified_users.include?(@all_events_user) | |
999 end | |
1000 | |
1001 should "not include users with the 'none' notification option" do | |
1002 assert !@project.notified_users.include?(@no_events_user) | |
1003 end | |
1004 | |
1005 should "not include users with the 'only_my_events' notification option" do | |
1006 assert !@project.notified_users.include?(@only_my_events_user) | |
1007 end | |
1008 | |
1009 should "not include users with the 'only_assigned' notification option" do | |
1010 assert !@project.notified_users.include?(@only_assigned_user) | |
1011 end | |
1012 | |
1013 should "not include users with the 'only_owner' notification option" do | |
1014 assert !@project.notified_users.include?(@only_owned_user) | |
1015 end | |
1016 end | |
1017 | |
963 end | 1018 end |