@@ -1,70 +1,82 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class WatchersController < ApplicationController |
|
18 | class WatchersController < ApplicationController | |
19 | before_filter :find_project |
|
19 | before_filter :find_project | |
20 | before_filter :require_login, :check_project_privacy, :only => [:watch, :unwatch] |
|
20 | before_filter :require_login, :check_project_privacy, :only => [:watch, :unwatch] | |
21 | before_filter :authorize, :only => :new |
|
21 | before_filter :authorize, :only => [:new, :destroy] | |
22 |
|
22 | |||
23 | verify :method => :post, |
|
23 | verify :method => :post, | |
24 | :only => [ :watch, :unwatch ], |
|
24 | :only => [ :watch, :unwatch ], | |
25 | :render => { :nothing => true, :status => :method_not_allowed } |
|
25 | :render => { :nothing => true, :status => :method_not_allowed } | |
26 |
|
26 | |||
27 | def watch |
|
27 | def watch | |
28 | set_watcher(User.current, true) |
|
28 | set_watcher(User.current, true) | |
29 | end |
|
29 | end | |
30 |
|
30 | |||
31 | def unwatch |
|
31 | def unwatch | |
32 | set_watcher(User.current, false) |
|
32 | set_watcher(User.current, false) | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
35 | def new |
|
35 | def new | |
36 | @watcher = Watcher.new(params[:watcher]) |
|
36 | @watcher = Watcher.new(params[:watcher]) | |
37 | @watcher.watchable = @watched |
|
37 | @watcher.watchable = @watched | |
38 | @watcher.save if request.post? |
|
38 | @watcher.save if request.post? | |
39 | respond_to do |format| |
|
39 | respond_to do |format| | |
40 | format.html { redirect_to :back } |
|
40 | format.html { redirect_to :back } | |
41 | format.js do |
|
41 | format.js do | |
42 | render :update do |page| |
|
42 | render :update do |page| | |
43 | page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched} |
|
43 | page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched} | |
44 | end |
|
44 | end | |
45 | end |
|
45 | end | |
46 | end |
|
46 | end | |
47 | rescue ::ActionController::RedirectBackError |
|
47 | rescue ::ActionController::RedirectBackError | |
48 | render :text => 'Watcher added.', :layout => true |
|
48 | render :text => 'Watcher added.', :layout => true | |
49 | end |
|
49 | end | |
50 |
|
50 | |||
|
51 | def destroy | |||
|
52 | @watched.set_watcher(User.find(params[:user_id]), false) if request.post? | |||
|
53 | respond_to do |format| | |||
|
54 | format.html { redirect_to :back } | |||
|
55 | format.js do | |||
|
56 | render :update do |page| | |||
|
57 | page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched} | |||
|
58 | end | |||
|
59 | end | |||
|
60 | end | |||
|
61 | end | |||
|
62 | ||||
51 | private |
|
63 | private | |
52 | def find_project |
|
64 | def find_project | |
53 | klass = Object.const_get(params[:object_type].camelcase) |
|
65 | klass = Object.const_get(params[:object_type].camelcase) | |
54 | return false unless klass.respond_to?('watched_by') |
|
66 | return false unless klass.respond_to?('watched_by') | |
55 | @watched = klass.find(params[:object_id]) |
|
67 | @watched = klass.find(params[:object_id]) | |
56 | @project = @watched.project |
|
68 | @project = @watched.project | |
57 | rescue |
|
69 | rescue | |
58 | render_404 |
|
70 | render_404 | |
59 | end |
|
71 | end | |
60 |
|
72 | |||
61 | def set_watcher(user, watching) |
|
73 | def set_watcher(user, watching) | |
62 | @watched.set_watcher(user, watching) |
|
74 | @watched.set_watcher(user, watching) | |
63 | respond_to do |format| |
|
75 | respond_to do |format| | |
64 | format.html { redirect_to :back } |
|
76 | format.html { redirect_to :back } | |
65 | format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} } |
|
77 | format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} } | |
66 | end |
|
78 | end | |
67 | rescue ::ActionController::RedirectBackError |
|
79 | rescue ::ActionController::RedirectBackError | |
68 | render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true |
|
80 | render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true | |
69 | end |
|
81 | end | |
70 | end |
|
82 | end |
@@ -1,41 +1,56 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | module WatchersHelper |
|
18 | module WatchersHelper | |
19 | def watcher_tag(object, user) |
|
19 | def watcher_tag(object, user) | |
20 | content_tag("span", watcher_link(object, user), :id => 'watcher') |
|
20 | content_tag("span", watcher_link(object, user), :id => 'watcher') | |
21 | end |
|
21 | end | |
22 |
|
22 | |||
23 | def watcher_link(object, user) |
|
23 | def watcher_link(object, user) | |
24 | return '' unless user && user.logged? && object.respond_to?('watched_by?') |
|
24 | return '' unless user && user.logged? && object.respond_to?('watched_by?') | |
25 | watched = object.watched_by?(user) |
|
25 | watched = object.watched_by?(user) | |
26 | url = {:controller => 'watchers', |
|
26 | url = {:controller => 'watchers', | |
27 | :action => (watched ? 'unwatch' : 'watch'), |
|
27 | :action => (watched ? 'unwatch' : 'watch'), | |
28 | :object_type => object.class.to_s.underscore, |
|
28 | :object_type => object.class.to_s.underscore, | |
29 | :object_id => object.id} |
|
29 | :object_id => object.id} | |
30 | link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)), |
|
30 | link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)), | |
31 | {:url => url}, |
|
31 | {:url => url}, | |
32 | :href => url_for(url), |
|
32 | :href => url_for(url), | |
33 | :class => (watched ? 'icon icon-fav' : 'icon icon-fav-off')) |
|
33 | :class => (watched ? 'icon icon-fav' : 'icon icon-fav-off')) | |
34 |
|
34 | |||
35 | end |
|
35 | end | |
36 |
|
36 | |||
37 | # Returns a comma separated list of users watching the given object |
|
37 | # Returns a comma separated list of users watching the given object | |
38 | def watchers_list(object) |
|
38 | def watchers_list(object) | |
39 | object.watcher_users.collect {|u| content_tag('span', link_to_user(u), :class => 'user') }.join(",\n") |
|
39 | remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project) | |
|
40 | object.watcher_users.collect do |user| | |||
|
41 | s = content_tag('span', link_to_user(user), :class => 'user') | |||
|
42 | if remove_allowed | |||
|
43 | url = {:controller => 'watchers', | |||
|
44 | :action => 'destroy', | |||
|
45 | :object_type => object.class.to_s.underscore, | |||
|
46 | :object_id => object.id, | |||
|
47 | :user_id => user} | |||
|
48 | s += ' ' + link_to_remote(image_tag('delete.png'), | |||
|
49 | {:url => url}, | |||
|
50 | :href => url_for(url), | |||
|
51 | :style => "vertical-align: middle") | |||
|
52 | end | |||
|
53 | s | |||
|
54 | end.join(",\n") | |||
40 | end |
|
55 | end | |
41 | end |
|
56 | end |
@@ -1,166 +1,167 | |||||
1 | require 'redmine/access_control' |
|
1 | require 'redmine/access_control' | |
2 | require 'redmine/menu_manager' |
|
2 | require 'redmine/menu_manager' | |
3 | require 'redmine/activity' |
|
3 | require 'redmine/activity' | |
4 | require 'redmine/mime_type' |
|
4 | require 'redmine/mime_type' | |
5 | require 'redmine/core_ext' |
|
5 | require 'redmine/core_ext' | |
6 | require 'redmine/themes' |
|
6 | require 'redmine/themes' | |
7 | require 'redmine/hook' |
|
7 | require 'redmine/hook' | |
8 | require 'redmine/plugin' |
|
8 | require 'redmine/plugin' | |
9 | require 'redmine/wiki_formatting' |
|
9 | require 'redmine/wiki_formatting' | |
10 |
|
10 | |||
11 | begin |
|
11 | begin | |
12 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) |
|
12 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) | |
13 | rescue LoadError |
|
13 | rescue LoadError | |
14 | # RMagick is not available |
|
14 | # RMagick is not available | |
15 | end |
|
15 | end | |
16 |
|
16 | |||
17 | REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs Bazaar Git Filesystem ) |
|
17 | REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs Bazaar Git Filesystem ) | |
18 |
|
18 | |||
19 | # Permissions |
|
19 | # Permissions | |
20 | Redmine::AccessControl.map do |map| |
|
20 | Redmine::AccessControl.map do |map| | |
21 | map.permission :view_project, {:projects => [:show, :activity]}, :public => true |
|
21 | map.permission :view_project, {:projects => [:show, :activity]}, :public => true | |
22 | map.permission :search_project, {:search => :index}, :public => true |
|
22 | map.permission :search_project, {:search => :index}, :public => true | |
23 | map.permission :add_project, {:projects => :add}, :require => :loggedin |
|
23 | map.permission :add_project, {:projects => :add}, :require => :loggedin | |
24 | map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member |
|
24 | map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member | |
25 | map.permission :select_project_modules, {:projects => :modules}, :require => :member |
|
25 | map.permission :select_project_modules, {:projects => :modules}, :require => :member | |
26 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member |
|
26 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member | |
27 | map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member |
|
27 | map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member | |
28 |
|
28 | |||
29 | map.project_module :issue_tracking do |map| |
|
29 | map.project_module :issue_tracking do |map| | |
30 | # Issue categories |
|
30 | # Issue categories | |
31 | map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member |
|
31 | map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member | |
32 | # Issues |
|
32 | # Issues | |
33 | map.permission :view_issues, {:projects => [:changelog, :roadmap], |
|
33 | map.permission :view_issues, {:projects => [:changelog, :roadmap], | |
34 | :issues => [:index, :changes, :show, :context_menu], |
|
34 | :issues => [:index, :changes, :show, :context_menu], | |
35 | :versions => [:show, :status_by], |
|
35 | :versions => [:show, :status_by], | |
36 | :queries => :index, |
|
36 | :queries => :index, | |
37 | :reports => :issue_report}, :public => true |
|
37 | :reports => :issue_report}, :public => true | |
38 | map.permission :add_issues, {:issues => :new} |
|
38 | map.permission :add_issues, {:issues => :new} | |
39 | map.permission :edit_issues, {:issues => [:edit, :reply, :bulk_edit]} |
|
39 | map.permission :edit_issues, {:issues => [:edit, :reply, :bulk_edit]} | |
40 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} |
|
40 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} | |
41 | map.permission :add_issue_notes, {:issues => [:edit, :reply]} |
|
41 | map.permission :add_issue_notes, {:issues => [:edit, :reply]} | |
42 | map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin |
|
42 | map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin | |
43 | map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin |
|
43 | map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin | |
44 | map.permission :move_issues, {:issues => :move}, :require => :loggedin |
|
44 | map.permission :move_issues, {:issues => :move}, :require => :loggedin | |
45 | map.permission :delete_issues, {:issues => :destroy}, :require => :member |
|
45 | map.permission :delete_issues, {:issues => :destroy}, :require => :member | |
46 | # Queries |
|
46 | # Queries | |
47 | map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member |
|
47 | map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member | |
48 | map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin |
|
48 | map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin | |
49 | # Gantt & calendar |
|
49 | # Gantt & calendar | |
50 | map.permission :view_gantt, :issues => :gantt |
|
50 | map.permission :view_gantt, :issues => :gantt | |
51 | map.permission :view_calendar, :issues => :calendar |
|
51 | map.permission :view_calendar, :issues => :calendar | |
52 | # Watchers |
|
52 | # Watchers | |
53 | map.permission :view_issue_watchers, {} |
|
53 | map.permission :view_issue_watchers, {} | |
54 | map.permission :add_issue_watchers, {:watchers => :new} |
|
54 | map.permission :add_issue_watchers, {:watchers => :new} | |
|
55 | map.permission :delete_issue_watchers, {:watchers => :destroy} | |||
55 | end |
|
56 | end | |
56 |
|
57 | |||
57 | map.project_module :time_tracking do |map| |
|
58 | map.project_module :time_tracking do |map| | |
58 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin |
|
59 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin | |
59 | map.permission :view_time_entries, :timelog => [:details, :report] |
|
60 | map.permission :view_time_entries, :timelog => [:details, :report] | |
60 | map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member |
|
61 | map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member | |
61 | map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin |
|
62 | map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin | |
62 | map.permission :manage_project_activities, {:projects => [:save_activities, :reset_activities]}, :require => :member |
|
63 | map.permission :manage_project_activities, {:projects => [:save_activities, :reset_activities]}, :require => :member | |
63 | end |
|
64 | end | |
64 |
|
65 | |||
65 | map.project_module :news do |map| |
|
66 | map.project_module :news do |map| | |
66 | map.permission :manage_news, {:news => [:new, :edit, :destroy, :destroy_comment]}, :require => :member |
|
67 | map.permission :manage_news, {:news => [:new, :edit, :destroy, :destroy_comment]}, :require => :member | |
67 | map.permission :view_news, {:news => [:index, :show]}, :public => true |
|
68 | map.permission :view_news, {:news => [:index, :show]}, :public => true | |
68 | map.permission :comment_news, {:news => :add_comment} |
|
69 | map.permission :comment_news, {:news => :add_comment} | |
69 | end |
|
70 | end | |
70 |
|
71 | |||
71 | map.project_module :documents do |map| |
|
72 | map.project_module :documents do |map| | |
72 | map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment]}, :require => :loggedin |
|
73 | map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment]}, :require => :loggedin | |
73 | map.permission :view_documents, :documents => [:index, :show, :download] |
|
74 | map.permission :view_documents, :documents => [:index, :show, :download] | |
74 | end |
|
75 | end | |
75 |
|
76 | |||
76 | map.project_module :files do |map| |
|
77 | map.project_module :files do |map| | |
77 | map.permission :manage_files, {:projects => :add_file}, :require => :loggedin |
|
78 | map.permission :manage_files, {:projects => :add_file}, :require => :loggedin | |
78 | map.permission :view_files, :projects => :list_files, :versions => :download |
|
79 | map.permission :view_files, :projects => :list_files, :versions => :download | |
79 | end |
|
80 | end | |
80 |
|
81 | |||
81 | map.project_module :wiki do |map| |
|
82 | map.project_module :wiki do |map| | |
82 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member |
|
83 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member | |
83 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member |
|
84 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member | |
84 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member |
|
85 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member | |
85 | map.permission :view_wiki_pages, :wiki => [:index, :special] |
|
86 | map.permission :view_wiki_pages, :wiki => [:index, :special] | |
86 | map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] |
|
87 | map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] | |
87 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment] |
|
88 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment] | |
88 | map.permission :delete_wiki_pages_attachments, {} |
|
89 | map.permission :delete_wiki_pages_attachments, {} | |
89 | map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member |
|
90 | map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member | |
90 | end |
|
91 | end | |
91 |
|
92 | |||
92 | map.project_module :repository do |map| |
|
93 | map.project_module :repository do |map| | |
93 | map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member |
|
94 | map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member | |
94 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] |
|
95 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] | |
95 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] |
|
96 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] | |
96 | map.permission :commit_access, {} |
|
97 | map.permission :commit_access, {} | |
97 | end |
|
98 | end | |
98 |
|
99 | |||
99 | map.project_module :boards do |map| |
|
100 | map.project_module :boards do |map| | |
100 | map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member |
|
101 | map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member | |
101 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true |
|
102 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true | |
102 | map.permission :add_messages, {:messages => [:new, :reply, :quote]} |
|
103 | map.permission :add_messages, {:messages => [:new, :reply, :quote]} | |
103 | map.permission :edit_messages, {:messages => :edit}, :require => :member |
|
104 | map.permission :edit_messages, {:messages => :edit}, :require => :member | |
104 | map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin |
|
105 | map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin | |
105 | map.permission :delete_messages, {:messages => :destroy}, :require => :member |
|
106 | map.permission :delete_messages, {:messages => :destroy}, :require => :member | |
106 | map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin |
|
107 | map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin | |
107 | end |
|
108 | end | |
108 | end |
|
109 | end | |
109 |
|
110 | |||
110 | Redmine::MenuManager.map :top_menu do |menu| |
|
111 | Redmine::MenuManager.map :top_menu do |menu| | |
111 | menu.push :home, :home_path |
|
112 | menu.push :home, :home_path | |
112 | menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } |
|
113 | menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } | |
113 | menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural |
|
114 | menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural | |
114 | menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true |
|
115 | menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true | |
115 | menu.push :help, Redmine::Info.help_url, :last => true |
|
116 | menu.push :help, Redmine::Info.help_url, :last => true | |
116 | end |
|
117 | end | |
117 |
|
118 | |||
118 | Redmine::MenuManager.map :account_menu do |menu| |
|
119 | Redmine::MenuManager.map :account_menu do |menu| | |
119 | menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? } |
|
120 | menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? } | |
120 | menu.push :register, { :controller => 'account', :action => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? } |
|
121 | menu.push :register, { :controller => 'account', :action => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? } | |
121 | menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? } |
|
122 | menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? } | |
122 | menu.push :logout, :signout_path, :if => Proc.new { User.current.logged? } |
|
123 | menu.push :logout, :signout_path, :if => Proc.new { User.current.logged? } | |
123 | end |
|
124 | end | |
124 |
|
125 | |||
125 | Redmine::MenuManager.map :application_menu do |menu| |
|
126 | Redmine::MenuManager.map :application_menu do |menu| | |
126 | # Empty |
|
127 | # Empty | |
127 | end |
|
128 | end | |
128 |
|
129 | |||
129 | Redmine::MenuManager.map :admin_menu do |menu| |
|
130 | Redmine::MenuManager.map :admin_menu do |menu| | |
130 | # Empty |
|
131 | # Empty | |
131 | end |
|
132 | end | |
132 |
|
133 | |||
133 | Redmine::MenuManager.map :project_menu do |menu| |
|
134 | Redmine::MenuManager.map :project_menu do |menu| | |
134 | menu.push :overview, { :controller => 'projects', :action => 'show' } |
|
135 | menu.push :overview, { :controller => 'projects', :action => 'show' } | |
135 | menu.push :activity, { :controller => 'projects', :action => 'activity' } |
|
136 | menu.push :activity, { :controller => 'projects', :action => 'activity' } | |
136 | menu.push :roadmap, { :controller => 'projects', :action => 'roadmap' }, |
|
137 | menu.push :roadmap, { :controller => 'projects', :action => 'roadmap' }, | |
137 | :if => Proc.new { |p| p.versions.any? } |
|
138 | :if => Proc.new { |p| p.versions.any? } | |
138 | menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural |
|
139 | menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural | |
139 | menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new, |
|
140 | menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new, | |
140 | :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } |
|
141 | :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } | |
141 | menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural |
|
142 | menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural | |
142 | menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural |
|
143 | menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural | |
143 | menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil }, |
|
144 | menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil }, | |
144 | :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } |
|
145 | :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } | |
145 | menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, |
|
146 | menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, | |
146 | :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural |
|
147 | :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural | |
147 | menu.push :files, { :controller => 'projects', :action => 'list_files' }, :caption => :label_attachment_plural |
|
148 | menu.push :files, { :controller => 'projects', :action => 'list_files' }, :caption => :label_attachment_plural | |
148 | menu.push :repository, { :controller => 'repositories', :action => 'show' }, |
|
149 | menu.push :repository, { :controller => 'repositories', :action => 'show' }, | |
149 | :if => Proc.new { |p| p.repository && !p.repository.new_record? } |
|
150 | :if => Proc.new { |p| p.repository && !p.repository.new_record? } | |
150 | menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true |
|
151 | menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true | |
151 | end |
|
152 | end | |
152 |
|
153 | |||
153 | Redmine::Activity.map do |activity| |
|
154 | Redmine::Activity.map do |activity| | |
154 | activity.register :issues, :class_name => %w(Issue Journal) |
|
155 | activity.register :issues, :class_name => %w(Issue Journal) | |
155 | activity.register :changesets |
|
156 | activity.register :changesets | |
156 | activity.register :news |
|
157 | activity.register :news | |
157 | activity.register :documents, :class_name => %w(Document Attachment) |
|
158 | activity.register :documents, :class_name => %w(Document Attachment) | |
158 | activity.register :files, :class_name => 'Attachment' |
|
159 | activity.register :files, :class_name => 'Attachment' | |
159 | activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false |
|
160 | activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false | |
160 | activity.register :messages, :default => false |
|
161 | activity.register :messages, :default => false | |
161 | activity.register :time_entries, :default => false |
|
162 | activity.register :time_entries, :default => false | |
162 | end |
|
163 | end | |
163 |
|
164 | |||
164 | Redmine::WikiFormatting.map do |format| |
|
165 | Redmine::WikiFormatting.map do |format| | |
165 | format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper |
|
166 | format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper | |
166 | end |
|
167 | end |
@@ -1,178 +1,179 | |||||
1 | --- |
|
1 | --- | |
2 | roles_001: |
|
2 | roles_001: | |
3 | name: Manager |
|
3 | name: Manager | |
4 | id: 1 |
|
4 | id: 1 | |
5 | builtin: 0 |
|
5 | builtin: 0 | |
6 | permissions: | |
|
6 | permissions: | | |
7 | --- |
|
7 | --- | |
8 | - :add_project |
|
8 | - :add_project | |
9 | - :edit_project |
|
9 | - :edit_project | |
10 | - :manage_members |
|
10 | - :manage_members | |
11 | - :manage_versions |
|
11 | - :manage_versions | |
12 | - :manage_categories |
|
12 | - :manage_categories | |
13 | - :add_issues |
|
13 | - :add_issues | |
14 | - :edit_issues |
|
14 | - :edit_issues | |
15 | - :manage_issue_relations |
|
15 | - :manage_issue_relations | |
16 | - :add_issue_notes |
|
16 | - :add_issue_notes | |
17 | - :move_issues |
|
17 | - :move_issues | |
18 | - :delete_issues |
|
18 | - :delete_issues | |
19 | - :view_issue_watchers |
|
19 | - :view_issue_watchers | |
20 | - :add_issue_watchers |
|
20 | - :add_issue_watchers | |
|
21 | - :delete_issue_watchers | |||
21 | - :manage_public_queries |
|
22 | - :manage_public_queries | |
22 | - :save_queries |
|
23 | - :save_queries | |
23 | - :view_gantt |
|
24 | - :view_gantt | |
24 | - :view_calendar |
|
25 | - :view_calendar | |
25 | - :log_time |
|
26 | - :log_time | |
26 | - :view_time_entries |
|
27 | - :view_time_entries | |
27 | - :edit_time_entries |
|
28 | - :edit_time_entries | |
28 | - :delete_time_entries |
|
29 | - :delete_time_entries | |
29 | - :manage_news |
|
30 | - :manage_news | |
30 | - :comment_news |
|
31 | - :comment_news | |
31 | - :view_documents |
|
32 | - :view_documents | |
32 | - :manage_documents |
|
33 | - :manage_documents | |
33 | - :view_wiki_pages |
|
34 | - :view_wiki_pages | |
34 | - :view_wiki_edits |
|
35 | - :view_wiki_edits | |
35 | - :edit_wiki_pages |
|
36 | - :edit_wiki_pages | |
36 | - :delete_wiki_pages_attachments |
|
37 | - :delete_wiki_pages_attachments | |
37 | - :protect_wiki_pages |
|
38 | - :protect_wiki_pages | |
38 | - :delete_wiki_pages |
|
39 | - :delete_wiki_pages | |
39 | - :rename_wiki_pages |
|
40 | - :rename_wiki_pages | |
40 | - :add_messages |
|
41 | - :add_messages | |
41 | - :edit_messages |
|
42 | - :edit_messages | |
42 | - :delete_messages |
|
43 | - :delete_messages | |
43 | - :manage_boards |
|
44 | - :manage_boards | |
44 | - :view_files |
|
45 | - :view_files | |
45 | - :manage_files |
|
46 | - :manage_files | |
46 | - :browse_repository |
|
47 | - :browse_repository | |
47 | - :manage_repository |
|
48 | - :manage_repository | |
48 | - :view_changesets |
|
49 | - :view_changesets | |
49 | - :manage_project_activities |
|
50 | - :manage_project_activities | |
50 |
|
51 | |||
51 | position: 1 |
|
52 | position: 1 | |
52 | roles_002: |
|
53 | roles_002: | |
53 | name: Developer |
|
54 | name: Developer | |
54 | id: 2 |
|
55 | id: 2 | |
55 | builtin: 0 |
|
56 | builtin: 0 | |
56 | permissions: | |
|
57 | permissions: | | |
57 | --- |
|
58 | --- | |
58 | - :edit_project |
|
59 | - :edit_project | |
59 | - :manage_members |
|
60 | - :manage_members | |
60 | - :manage_versions |
|
61 | - :manage_versions | |
61 | - :manage_categories |
|
62 | - :manage_categories | |
62 | - :add_issues |
|
63 | - :add_issues | |
63 | - :edit_issues |
|
64 | - :edit_issues | |
64 | - :manage_issue_relations |
|
65 | - :manage_issue_relations | |
65 | - :add_issue_notes |
|
66 | - :add_issue_notes | |
66 | - :move_issues |
|
67 | - :move_issues | |
67 | - :delete_issues |
|
68 | - :delete_issues | |
68 | - :view_issue_watchers |
|
69 | - :view_issue_watchers | |
69 | - :save_queries |
|
70 | - :save_queries | |
70 | - :view_gantt |
|
71 | - :view_gantt | |
71 | - :view_calendar |
|
72 | - :view_calendar | |
72 | - :log_time |
|
73 | - :log_time | |
73 | - :view_time_entries |
|
74 | - :view_time_entries | |
74 | - :edit_own_time_entries |
|
75 | - :edit_own_time_entries | |
75 | - :manage_news |
|
76 | - :manage_news | |
76 | - :comment_news |
|
77 | - :comment_news | |
77 | - :view_documents |
|
78 | - :view_documents | |
78 | - :manage_documents |
|
79 | - :manage_documents | |
79 | - :view_wiki_pages |
|
80 | - :view_wiki_pages | |
80 | - :view_wiki_edits |
|
81 | - :view_wiki_edits | |
81 | - :edit_wiki_pages |
|
82 | - :edit_wiki_pages | |
82 | - :protect_wiki_pages |
|
83 | - :protect_wiki_pages | |
83 | - :delete_wiki_pages |
|
84 | - :delete_wiki_pages | |
84 | - :add_messages |
|
85 | - :add_messages | |
85 | - :edit_own_messages |
|
86 | - :edit_own_messages | |
86 | - :delete_own_messages |
|
87 | - :delete_own_messages | |
87 | - :manage_boards |
|
88 | - :manage_boards | |
88 | - :view_files |
|
89 | - :view_files | |
89 | - :manage_files |
|
90 | - :manage_files | |
90 | - :browse_repository |
|
91 | - :browse_repository | |
91 | - :view_changesets |
|
92 | - :view_changesets | |
92 |
|
93 | |||
93 | position: 2 |
|
94 | position: 2 | |
94 | roles_003: |
|
95 | roles_003: | |
95 | name: Reporter |
|
96 | name: Reporter | |
96 | id: 3 |
|
97 | id: 3 | |
97 | builtin: 0 |
|
98 | builtin: 0 | |
98 | permissions: | |
|
99 | permissions: | | |
99 | --- |
|
100 | --- | |
100 | - :edit_project |
|
101 | - :edit_project | |
101 | - :manage_members |
|
102 | - :manage_members | |
102 | - :manage_versions |
|
103 | - :manage_versions | |
103 | - :manage_categories |
|
104 | - :manage_categories | |
104 | - :add_issues |
|
105 | - :add_issues | |
105 | - :edit_issues |
|
106 | - :edit_issues | |
106 | - :manage_issue_relations |
|
107 | - :manage_issue_relations | |
107 | - :add_issue_notes |
|
108 | - :add_issue_notes | |
108 | - :move_issues |
|
109 | - :move_issues | |
109 | - :view_issue_watchers |
|
110 | - :view_issue_watchers | |
110 | - :save_queries |
|
111 | - :save_queries | |
111 | - :view_gantt |
|
112 | - :view_gantt | |
112 | - :view_calendar |
|
113 | - :view_calendar | |
113 | - :log_time |
|
114 | - :log_time | |
114 | - :view_time_entries |
|
115 | - :view_time_entries | |
115 | - :manage_news |
|
116 | - :manage_news | |
116 | - :comment_news |
|
117 | - :comment_news | |
117 | - :view_documents |
|
118 | - :view_documents | |
118 | - :manage_documents |
|
119 | - :manage_documents | |
119 | - :view_wiki_pages |
|
120 | - :view_wiki_pages | |
120 | - :view_wiki_edits |
|
121 | - :view_wiki_edits | |
121 | - :edit_wiki_pages |
|
122 | - :edit_wiki_pages | |
122 | - :delete_wiki_pages |
|
123 | - :delete_wiki_pages | |
123 | - :add_messages |
|
124 | - :add_messages | |
124 | - :manage_boards |
|
125 | - :manage_boards | |
125 | - :view_files |
|
126 | - :view_files | |
126 | - :manage_files |
|
127 | - :manage_files | |
127 | - :browse_repository |
|
128 | - :browse_repository | |
128 | - :view_changesets |
|
129 | - :view_changesets | |
129 |
|
130 | |||
130 | position: 3 |
|
131 | position: 3 | |
131 | roles_004: |
|
132 | roles_004: | |
132 | name: Non member |
|
133 | name: Non member | |
133 | id: 4 |
|
134 | id: 4 | |
134 | builtin: 1 |
|
135 | builtin: 1 | |
135 | permissions: | |
|
136 | permissions: | | |
136 | --- |
|
137 | --- | |
137 | - :add_issues |
|
138 | - :add_issues | |
138 | - :edit_issues |
|
139 | - :edit_issues | |
139 | - :manage_issue_relations |
|
140 | - :manage_issue_relations | |
140 | - :add_issue_notes |
|
141 | - :add_issue_notes | |
141 | - :move_issues |
|
142 | - :move_issues | |
142 | - :save_queries |
|
143 | - :save_queries | |
143 | - :view_gantt |
|
144 | - :view_gantt | |
144 | - :view_calendar |
|
145 | - :view_calendar | |
145 | - :log_time |
|
146 | - :log_time | |
146 | - :view_time_entries |
|
147 | - :view_time_entries | |
147 | - :comment_news |
|
148 | - :comment_news | |
148 | - :view_documents |
|
149 | - :view_documents | |
149 | - :manage_documents |
|
150 | - :manage_documents | |
150 | - :view_wiki_pages |
|
151 | - :view_wiki_pages | |
151 | - :view_wiki_edits |
|
152 | - :view_wiki_edits | |
152 | - :edit_wiki_pages |
|
153 | - :edit_wiki_pages | |
153 | - :add_messages |
|
154 | - :add_messages | |
154 | - :view_files |
|
155 | - :view_files | |
155 | - :manage_files |
|
156 | - :manage_files | |
156 | - :browse_repository |
|
157 | - :browse_repository | |
157 | - :view_changesets |
|
158 | - :view_changesets | |
158 |
|
159 | |||
159 | position: 4 |
|
160 | position: 4 | |
160 | roles_005: |
|
161 | roles_005: | |
161 | name: Anonymous |
|
162 | name: Anonymous | |
162 | id: 5 |
|
163 | id: 5 | |
163 | builtin: 2 |
|
164 | builtin: 2 | |
164 | permissions: | |
|
165 | permissions: | | |
165 | --- |
|
166 | --- | |
166 | - :add_issue_notes |
|
167 | - :add_issue_notes | |
167 | - :view_gantt |
|
168 | - :view_gantt | |
168 | - :view_calendar |
|
169 | - :view_calendar | |
169 | - :view_time_entries |
|
170 | - :view_time_entries | |
170 | - :view_documents |
|
171 | - :view_documents | |
171 | - :view_wiki_pages |
|
172 | - :view_wiki_pages | |
172 | - :view_wiki_edits |
|
173 | - :view_wiki_edits | |
173 | - :view_files |
|
174 | - :view_files | |
174 | - :browse_repository |
|
175 | - :browse_repository | |
175 | - :view_changesets |
|
176 | - :view_changesets | |
176 |
|
177 | |||
177 | position: 5 |
|
178 | position: 5 | |
178 |
|
179 |
@@ -1,70 +1,80 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 | require 'watchers_controller' |
|
19 | require 'watchers_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class WatchersController; def rescue_action(e) raise e end; end |
|
22 | class WatchersController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class WatchersControllerTest < ActionController::TestCase |
|
24 | class WatchersControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, |
|
25 | fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, | |
26 | :issues, :trackers, :projects_trackers, :issue_statuses, :enumerations, :watchers |
|
26 | :issues, :trackers, :projects_trackers, :issue_statuses, :enumerations, :watchers | |
27 |
|
27 | |||
28 | def setup |
|
28 | def setup | |
29 | @controller = WatchersController.new |
|
29 | @controller = WatchersController.new | |
30 | @request = ActionController::TestRequest.new |
|
30 | @request = ActionController::TestRequest.new | |
31 | @response = ActionController::TestResponse.new |
|
31 | @response = ActionController::TestResponse.new | |
32 | User.current = nil |
|
32 | User.current = nil | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
35 | def test_get_watch_should_be_invalid |
|
35 | def test_get_watch_should_be_invalid | |
36 | @request.session[:user_id] = 3 |
|
36 | @request.session[:user_id] = 3 | |
37 | get :watch, :object_type => 'issue', :object_id => '1' |
|
37 | get :watch, :object_type => 'issue', :object_id => '1' | |
38 | assert_response 405 |
|
38 | assert_response 405 | |
39 | end |
|
39 | end | |
40 |
|
40 | |||
41 | def test_watch |
|
41 | def test_watch | |
42 | @request.session[:user_id] = 3 |
|
42 | @request.session[:user_id] = 3 | |
43 | assert_difference('Watcher.count') do |
|
43 | assert_difference('Watcher.count') do | |
44 | xhr :post, :watch, :object_type => 'issue', :object_id => '1' |
|
44 | xhr :post, :watch, :object_type => 'issue', :object_id => '1' | |
45 | assert_response :success |
|
45 | assert_response :success | |
46 | assert_select_rjs :replace_html, 'watcher' |
|
46 | assert_select_rjs :replace_html, 'watcher' | |
47 | end |
|
47 | end | |
48 | assert Issue.find(1).watched_by?(User.find(3)) |
|
48 | assert Issue.find(1).watched_by?(User.find(3)) | |
49 | end |
|
49 | end | |
50 |
|
50 | |||
51 | def test_unwatch |
|
51 | def test_unwatch | |
52 | @request.session[:user_id] = 3 |
|
52 | @request.session[:user_id] = 3 | |
53 | assert_difference('Watcher.count', -1) do |
|
53 | assert_difference('Watcher.count', -1) do | |
54 | xhr :post, :unwatch, :object_type => 'issue', :object_id => '2' |
|
54 | xhr :post, :unwatch, :object_type => 'issue', :object_id => '2' | |
55 | assert_response :success |
|
55 | assert_response :success | |
56 | assert_select_rjs :replace_html, 'watcher' |
|
56 | assert_select_rjs :replace_html, 'watcher' | |
57 | end |
|
57 | end | |
58 | assert !Issue.find(1).watched_by?(User.find(3)) |
|
58 | assert !Issue.find(1).watched_by?(User.find(3)) | |
59 | end |
|
59 | end | |
60 |
|
60 | |||
61 | def test_new_watcher |
|
61 | def test_new_watcher | |
62 | @request.session[:user_id] = 2 |
|
62 | @request.session[:user_id] = 2 | |
63 | assert_difference('Watcher.count') do |
|
63 | assert_difference('Watcher.count') do | |
64 | xhr :post, :new, :object_type => 'issue', :object_id => '2', :watcher => {:user_id => '4'} |
|
64 | xhr :post, :new, :object_type => 'issue', :object_id => '2', :watcher => {:user_id => '4'} | |
65 | assert_response :success |
|
65 | assert_response :success | |
66 | assert_select_rjs :replace_html, 'watchers' |
|
66 | assert_select_rjs :replace_html, 'watchers' | |
67 | end |
|
67 | end | |
68 | assert Issue.find(2).watched_by?(User.find(4)) |
|
68 | assert Issue.find(2).watched_by?(User.find(4)) | |
69 | end |
|
69 | end | |
|
70 | ||||
|
71 | def test_remove_watcher | |||
|
72 | @request.session[:user_id] = 2 | |||
|
73 | assert_difference('Watcher.count', -1) do | |||
|
74 | xhr :post, :destroy, :object_type => 'issue', :object_id => '2', :user_id => '3' | |||
|
75 | assert_response :success | |||
|
76 | assert_select_rjs :replace_html, 'watchers' | |||
|
77 | end | |||
|
78 | assert !Issue.find(2).watched_by?(User.find(3)) | |||
|
79 | end | |||
70 | end |
|
80 | end |
General Comments 0
You need to be logged in to leave comments.
Login now