@@ -1,166 +1,170 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2009 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2009 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 MyController < ApplicationController |
|
18 | class MyController < ApplicationController | |
19 | before_filter :require_login |
|
19 | before_filter :require_login | |
20 |
|
20 | |||
21 | helper :issues |
|
21 | helper :issues | |
22 | helper :custom_fields |
|
22 | helper :custom_fields | |
23 |
|
23 | |||
24 | BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues, |
|
24 | BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues, | |
25 | 'issuesreportedbyme' => :label_reported_issues, |
|
25 | 'issuesreportedbyme' => :label_reported_issues, | |
26 | 'issueswatched' => :label_watched_issues, |
|
26 | 'issueswatched' => :label_watched_issues, | |
27 | 'news' => :label_news_latest, |
|
27 | 'news' => :label_news_latest, | |
28 | 'calendar' => :label_calendar, |
|
28 | 'calendar' => :label_calendar, | |
29 | 'documents' => :label_document_plural, |
|
29 | 'documents' => :label_document_plural, | |
30 | 'timelog' => :label_spent_time |
|
30 | 'timelog' => :label_spent_time | |
31 | }.merge(Redmine::Views::MyPage::Block.additional_blocks).freeze |
|
31 | }.merge(Redmine::Views::MyPage::Block.additional_blocks).freeze | |
32 |
|
32 | |||
33 | DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'], |
|
33 | DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'], | |
34 | 'right' => ['issuesreportedbyme'] |
|
34 | 'right' => ['issuesreportedbyme'] | |
35 | }.freeze |
|
35 | }.freeze | |
36 |
|
36 | |||
37 | verify :xhr => true, |
|
37 | verify :xhr => true, | |
38 | :only => [:add_block, :remove_block, :order_blocks] |
|
38 | :only => [:add_block, :remove_block, :order_blocks] | |
39 |
|
39 | |||
40 | def index |
|
40 | def index | |
41 | page |
|
41 | page | |
42 | render :action => 'page' |
|
42 | render :action => 'page' | |
43 | end |
|
43 | end | |
44 |
|
44 | |||
45 | # Show user's page |
|
45 | # Show user's page | |
46 | def page |
|
46 | def page | |
47 | @user = User.current |
|
47 | @user = User.current | |
48 | @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT |
|
48 | @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT | |
49 | end |
|
49 | end | |
50 |
|
50 | |||
51 | # Edit user's account |
|
51 | # Edit user's account | |
52 | def account |
|
52 | def account | |
53 | @user = User.current |
|
53 | @user = User.current | |
54 | @pref = @user.pref |
|
54 | @pref = @user.pref | |
55 | if request.post? |
|
55 | if request.post? | |
56 | @user.attributes = params[:user] |
|
56 | @user.attributes = params[:user] | |
57 | @user.mail_notification = (params[:notification_option] == 'all') |
|
57 | @user.mail_notification = (params[:notification_option] == 'all') | |
58 | @user.pref.attributes = params[:pref] |
|
58 | @user.pref.attributes = params[:pref] | |
59 | @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') |
|
59 | @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') | |
60 | if @user.save |
|
60 | if @user.save | |
61 | @user.pref.save |
|
61 | @user.pref.save | |
62 | @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) |
|
62 | @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) | |
63 | set_language_if_valid @user.language |
|
63 | set_language_if_valid @user.language | |
64 | flash[:notice] = l(:notice_account_updated) |
|
64 | flash[:notice] = l(:notice_account_updated) | |
65 | redirect_to :action => 'account' |
|
65 | redirect_to :action => 'account' | |
66 | return |
|
66 | return | |
67 | end |
|
67 | end | |
68 | end |
|
68 | end | |
69 | @notification_options = [[l(:label_user_mail_option_all), 'all'], |
|
69 | @notification_options = [[l(:label_user_mail_option_all), 'all'], | |
70 | [l(:label_user_mail_option_none), 'none']] |
|
70 | [l(:label_user_mail_option_none), 'none']] | |
71 | # Only users that belong to more than 1 project can select projects for which they are notified |
|
71 | # Only users that belong to more than 1 project can select projects for which they are notified | |
72 | # Note that @user.membership.size would fail since AR ignores :include association option when doing a count |
|
72 | # Note that @user.membership.size would fail since AR ignores :include association option when doing a count | |
73 | @notification_options.insert 1, [l(:label_user_mail_option_selected), 'selected'] if @user.memberships.length > 1 |
|
73 | @notification_options.insert 1, [l(:label_user_mail_option_selected), 'selected'] if @user.memberships.length > 1 | |
74 | @notification_option = @user.mail_notification? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected') |
|
74 | @notification_option = @user.mail_notification? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected') | |
75 | end |
|
75 | end | |
76 |
|
76 | |||
77 | # Manage user's password |
|
77 | # Manage user's password | |
78 | def password |
|
78 | def password | |
79 | @user = User.current |
|
79 | @user = User.current | |
80 | if @user.auth_source_id |
|
80 | if @user.auth_source_id | |
81 | flash[:error] = l(:notice_can_t_change_password) |
|
81 | flash[:error] = l(:notice_can_t_change_password) | |
82 | redirect_to :action => 'account' |
|
82 | redirect_to :action => 'account' | |
83 | return |
|
83 | return | |
84 | end |
|
84 | end | |
85 | if request.post? |
|
85 | if request.post? | |
86 | if @user.check_password?(params[:password]) |
|
86 | if @user.check_password?(params[:password]) | |
87 | @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] |
|
87 | @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] | |
88 | if @user.save |
|
88 | if @user.save | |
89 | flash[:notice] = l(:notice_account_password_updated) |
|
89 | flash[:notice] = l(:notice_account_password_updated) | |
90 | redirect_to :action => 'account' |
|
90 | redirect_to :action => 'account' | |
91 | end |
|
91 | end | |
92 | else |
|
92 | else | |
93 | flash[:error] = l(:notice_account_wrong_password) |
|
93 | flash[:error] = l(:notice_account_wrong_password) | |
94 | end |
|
94 | end | |
95 | end |
|
95 | end | |
96 | end |
|
96 | end | |
97 |
|
97 | |||
98 | # Create a new feeds key |
|
98 | # Create a new feeds key | |
99 | def reset_rss_key |
|
99 | def reset_rss_key | |
100 |
if request.post? |
|
100 | if request.post? | |
101 |
User.current.rss_token |
|
101 | if User.current.rss_token | |
|
102 | User.current.rss_token.destroy | |||
|
103 | User.current.reload | |||
|
104 | end | |||
|
105 | User.current.rss_key | |||
102 | flash[:notice] = l(:notice_feeds_access_key_reseted) |
|
106 | flash[:notice] = l(:notice_feeds_access_key_reseted) | |
103 | end |
|
107 | end | |
104 | redirect_to :action => 'account' |
|
108 | redirect_to :action => 'account' | |
105 | end |
|
109 | end | |
106 |
|
110 | |||
107 | # User's page layout configuration |
|
111 | # User's page layout configuration | |
108 | def page_layout |
|
112 | def page_layout | |
109 | @user = User.current |
|
113 | @user = User.current | |
110 | @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup |
|
114 | @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup | |
111 | @block_options = [] |
|
115 | @block_options = [] | |
112 | BLOCKS.each {|k, v| @block_options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize]} |
|
116 | BLOCKS.each {|k, v| @block_options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize]} | |
113 | end |
|
117 | end | |
114 |
|
118 | |||
115 | # Add a block to user's page |
|
119 | # Add a block to user's page | |
116 | # The block is added on top of the page |
|
120 | # The block is added on top of the page | |
117 | # params[:block] : id of the block to add |
|
121 | # params[:block] : id of the block to add | |
118 | def add_block |
|
122 | def add_block | |
119 | block = params[:block].to_s.underscore |
|
123 | block = params[:block].to_s.underscore | |
120 | (render :nothing => true; return) unless block && (BLOCKS.keys.include? block) |
|
124 | (render :nothing => true; return) unless block && (BLOCKS.keys.include? block) | |
121 | @user = User.current |
|
125 | @user = User.current | |
122 | layout = @user.pref[:my_page_layout] || {} |
|
126 | layout = @user.pref[:my_page_layout] || {} | |
123 | # remove if already present in a group |
|
127 | # remove if already present in a group | |
124 | %w(top left right).each {|f| (layout[f] ||= []).delete block } |
|
128 | %w(top left right).each {|f| (layout[f] ||= []).delete block } | |
125 | # add it on top |
|
129 | # add it on top | |
126 | layout['top'].unshift block |
|
130 | layout['top'].unshift block | |
127 | @user.pref[:my_page_layout] = layout |
|
131 | @user.pref[:my_page_layout] = layout | |
128 | @user.pref.save |
|
132 | @user.pref.save | |
129 | render :partial => "block", :locals => {:user => @user, :block_name => block} |
|
133 | render :partial => "block", :locals => {:user => @user, :block_name => block} | |
130 | end |
|
134 | end | |
131 |
|
135 | |||
132 | # Remove a block to user's page |
|
136 | # Remove a block to user's page | |
133 | # params[:block] : id of the block to remove |
|
137 | # params[:block] : id of the block to remove | |
134 | def remove_block |
|
138 | def remove_block | |
135 | block = params[:block].to_s.underscore |
|
139 | block = params[:block].to_s.underscore | |
136 | @user = User.current |
|
140 | @user = User.current | |
137 | # remove block in all groups |
|
141 | # remove block in all groups | |
138 | layout = @user.pref[:my_page_layout] || {} |
|
142 | layout = @user.pref[:my_page_layout] || {} | |
139 | %w(top left right).each {|f| (layout[f] ||= []).delete block } |
|
143 | %w(top left right).each {|f| (layout[f] ||= []).delete block } | |
140 | @user.pref[:my_page_layout] = layout |
|
144 | @user.pref[:my_page_layout] = layout | |
141 | @user.pref.save |
|
145 | @user.pref.save | |
142 | render :nothing => true |
|
146 | render :nothing => true | |
143 | end |
|
147 | end | |
144 |
|
148 | |||
145 | # Change blocks order on user's page |
|
149 | # Change blocks order on user's page | |
146 | # params[:group] : group to order (top, left or right) |
|
150 | # params[:group] : group to order (top, left or right) | |
147 | # params[:list-(top|left|right)] : array of block ids of the group |
|
151 | # params[:list-(top|left|right)] : array of block ids of the group | |
148 | def order_blocks |
|
152 | def order_blocks | |
149 | group = params[:group] |
|
153 | group = params[:group] | |
150 | @user = User.current |
|
154 | @user = User.current | |
151 | if group.is_a?(String) |
|
155 | if group.is_a?(String) | |
152 | group_items = (params["list-#{group}"] || []).collect(&:underscore) |
|
156 | group_items = (params["list-#{group}"] || []).collect(&:underscore) | |
153 | if group_items and group_items.is_a? Array |
|
157 | if group_items and group_items.is_a? Array | |
154 | layout = @user.pref[:my_page_layout] || {} |
|
158 | layout = @user.pref[:my_page_layout] || {} | |
155 | # remove group blocks if they are presents in other groups |
|
159 | # remove group blocks if they are presents in other groups | |
156 | %w(top left right).each {|f| |
|
160 | %w(top left right).each {|f| | |
157 | layout[f] = (layout[f] || []) - group_items |
|
161 | layout[f] = (layout[f] || []) - group_items | |
158 | } |
|
162 | } | |
159 | layout[group] = group_items |
|
163 | layout[group] = group_items | |
160 | @user.pref[:my_page_layout] = layout |
|
164 | @user.pref[:my_page_layout] = layout | |
161 | @user.pref.save |
|
165 | @user.pref.save | |
162 | end |
|
166 | end | |
163 | end |
|
167 | end | |
164 | render :nothing => true |
|
168 | render :nothing => true | |
165 | end |
|
169 | end | |
166 | end |
|
170 | end |
@@ -1,132 +1,166 | |||||
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 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 | require 'my_controller' |
|
19 | require 'my_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class MyController; def rescue_action(e) raise e end; end |
|
22 | class MyController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class MyControllerTest < ActionController::TestCase |
|
24 | class MyControllerTest < ActionController::TestCase | |
25 | fixtures :users, :user_preferences, :roles, :projects, :issues, :issue_statuses, :trackers, :enumerations, :custom_fields |
|
25 | fixtures :users, :user_preferences, :roles, :projects, :issues, :issue_statuses, :trackers, :enumerations, :custom_fields | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = MyController.new |
|
28 | @controller = MyController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @request.session[:user_id] = 2 |
|
30 | @request.session[:user_id] = 2 | |
31 | @response = ActionController::TestResponse.new |
|
31 | @response = ActionController::TestResponse.new | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_index |
|
34 | def test_index | |
35 | get :index |
|
35 | get :index | |
36 | assert_response :success |
|
36 | assert_response :success | |
37 | assert_template 'page' |
|
37 | assert_template 'page' | |
38 | end |
|
38 | end | |
39 |
|
39 | |||
40 | def test_page |
|
40 | def test_page | |
41 | get :page |
|
41 | get :page | |
42 | assert_response :success |
|
42 | assert_response :success | |
43 | assert_template 'page' |
|
43 | assert_template 'page' | |
44 | end |
|
44 | end | |
45 |
|
45 | |||
46 | def test_my_account_should_show_editable_custom_fields |
|
46 | def test_my_account_should_show_editable_custom_fields | |
47 | get :account |
|
47 | get :account | |
48 | assert_response :success |
|
48 | assert_response :success | |
49 | assert_template 'account' |
|
49 | assert_template 'account' | |
50 | assert_equal User.find(2), assigns(:user) |
|
50 | assert_equal User.find(2), assigns(:user) | |
51 |
|
51 | |||
52 | assert_tag :input, :attributes => { :name => 'user[custom_field_values][4]'} |
|
52 | assert_tag :input, :attributes => { :name => 'user[custom_field_values][4]'} | |
53 | end |
|
53 | end | |
54 |
|
54 | |||
55 | def test_my_account_should_not_show_non_editable_custom_fields |
|
55 | def test_my_account_should_not_show_non_editable_custom_fields | |
56 | UserCustomField.find(4).update_attribute :editable, false |
|
56 | UserCustomField.find(4).update_attribute :editable, false | |
57 |
|
57 | |||
58 | get :account |
|
58 | get :account | |
59 | assert_response :success |
|
59 | assert_response :success | |
60 | assert_template 'account' |
|
60 | assert_template 'account' | |
61 | assert_equal User.find(2), assigns(:user) |
|
61 | assert_equal User.find(2), assigns(:user) | |
62 |
|
62 | |||
63 | assert_no_tag :input, :attributes => { :name => 'user[custom_field_values][4]'} |
|
63 | assert_no_tag :input, :attributes => { :name => 'user[custom_field_values][4]'} | |
64 | end |
|
64 | end | |
65 |
|
65 | |||
66 | def test_update_account |
|
66 | def test_update_account | |
67 | post :account, :user => {:firstname => "Joe", |
|
67 | post :account, :user => {:firstname => "Joe", | |
68 | :login => "root", |
|
68 | :login => "root", | |
69 | :admin => 1, |
|
69 | :admin => 1, | |
70 | :custom_field_values => {"4" => "0100562500"}} |
|
70 | :custom_field_values => {"4" => "0100562500"}} | |
71 | assert_redirected_to 'my/account' |
|
71 | assert_redirected_to 'my/account' | |
72 | user = User.find(2) |
|
72 | user = User.find(2) | |
73 | assert_equal user, assigns(:user) |
|
73 | assert_equal user, assigns(:user) | |
74 | assert_equal "Joe", user.firstname |
|
74 | assert_equal "Joe", user.firstname | |
75 | assert_equal "jsmith", user.login |
|
75 | assert_equal "jsmith", user.login | |
76 | assert_equal "0100562500", user.custom_value_for(4).value |
|
76 | assert_equal "0100562500", user.custom_value_for(4).value | |
77 | assert !user.admin? |
|
77 | assert !user.admin? | |
78 | end |
|
78 | end | |
79 |
|
79 | |||
80 | def test_change_password |
|
80 | def test_change_password | |
81 | get :password |
|
81 | get :password | |
82 | assert_response :success |
|
82 | assert_response :success | |
83 | assert_template 'password' |
|
83 | assert_template 'password' | |
84 |
|
84 | |||
85 | # non matching password confirmation |
|
85 | # non matching password confirmation | |
86 | post :password, :password => 'jsmith', |
|
86 | post :password, :password => 'jsmith', | |
87 | :new_password => 'hello', |
|
87 | :new_password => 'hello', | |
88 | :new_password_confirmation => 'hello2' |
|
88 | :new_password_confirmation => 'hello2' | |
89 | assert_response :success |
|
89 | assert_response :success | |
90 | assert_template 'password' |
|
90 | assert_template 'password' | |
91 | assert_tag :tag => "div", :attributes => { :class => "errorExplanation" } |
|
91 | assert_tag :tag => "div", :attributes => { :class => "errorExplanation" } | |
92 |
|
92 | |||
93 | # wrong password |
|
93 | # wrong password | |
94 | post :password, :password => 'wrongpassword', |
|
94 | post :password, :password => 'wrongpassword', | |
95 | :new_password => 'hello', |
|
95 | :new_password => 'hello', | |
96 | :new_password_confirmation => 'hello' |
|
96 | :new_password_confirmation => 'hello' | |
97 | assert_response :success |
|
97 | assert_response :success | |
98 | assert_template 'password' |
|
98 | assert_template 'password' | |
99 | assert_equal 'Wrong password', flash[:error] |
|
99 | assert_equal 'Wrong password', flash[:error] | |
100 |
|
100 | |||
101 | # good password |
|
101 | # good password | |
102 | post :password, :password => 'jsmith', |
|
102 | post :password, :password => 'jsmith', | |
103 | :new_password => 'hello', |
|
103 | :new_password => 'hello', | |
104 | :new_password_confirmation => 'hello' |
|
104 | :new_password_confirmation => 'hello' | |
105 | assert_redirected_to 'my/account' |
|
105 | assert_redirected_to 'my/account' | |
106 | assert User.try_to_login('jsmith', 'hello') |
|
106 | assert User.try_to_login('jsmith', 'hello') | |
107 | end |
|
107 | end | |
108 |
|
108 | |||
109 | def test_page_layout |
|
109 | def test_page_layout | |
110 | get :page_layout |
|
110 | get :page_layout | |
111 | assert_response :success |
|
111 | assert_response :success | |
112 | assert_template 'page_layout' |
|
112 | assert_template 'page_layout' | |
113 | end |
|
113 | end | |
114 |
|
114 | |||
115 | def test_add_block |
|
115 | def test_add_block | |
116 | xhr :post, :add_block, :block => 'issuesreportedbyme' |
|
116 | xhr :post, :add_block, :block => 'issuesreportedbyme' | |
117 | assert_response :success |
|
117 | assert_response :success | |
118 | assert User.find(2).pref[:my_page_layout]['top'].include?('issuesreportedbyme') |
|
118 | assert User.find(2).pref[:my_page_layout]['top'].include?('issuesreportedbyme') | |
119 | end |
|
119 | end | |
120 |
|
120 | |||
121 | def test_remove_block |
|
121 | def test_remove_block | |
122 | xhr :post, :remove_block, :block => 'issuesassignedtome' |
|
122 | xhr :post, :remove_block, :block => 'issuesassignedtome' | |
123 | assert_response :success |
|
123 | assert_response :success | |
124 | assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome') |
|
124 | assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome') | |
125 | end |
|
125 | end | |
126 |
|
126 | |||
127 | def test_order_blocks |
|
127 | def test_order_blocks | |
128 | xhr :post, :order_blocks, :group => 'left', 'list-left' => ['documents', 'calendar', 'latestnews'] |
|
128 | xhr :post, :order_blocks, :group => 'left', 'list-left' => ['documents', 'calendar', 'latestnews'] | |
129 | assert_response :success |
|
129 | assert_response :success | |
130 | assert_equal ['documents', 'calendar', 'latestnews'], User.find(2).pref[:my_page_layout]['left'] |
|
130 | assert_equal ['documents', 'calendar', 'latestnews'], User.find(2).pref[:my_page_layout]['left'] | |
131 | end |
|
131 | end | |
|
132 | ||||
|
133 | context "POST to reset_rss_key" do | |||
|
134 | context "with an existing rss_token" do | |||
|
135 | setup do | |||
|
136 | @previous_token_value = User.find(2).rss_key # Will generate one if it's missing | |||
|
137 | post :reset_rss_key | |||
|
138 | end | |||
|
139 | ||||
|
140 | should "destroy the existing token" do | |||
|
141 | assert_not_equal @previous_token_value, User.find(2).rss_key | |||
|
142 | end | |||
|
143 | ||||
|
144 | should "create a new token" do | |||
|
145 | assert User.find(2).rss_token | |||
|
146 | end | |||
|
147 | ||||
|
148 | should_set_the_flash_to /reset/ | |||
|
149 | should_redirect_to('my account') {'/my/account' } | |||
|
150 | end | |||
|
151 | ||||
|
152 | context "with no rss_token" do | |||
|
153 | setup do | |||
|
154 | assert_nil User.find(2).rss_token | |||
|
155 | post :reset_rss_key | |||
|
156 | end | |||
|
157 | ||||
|
158 | should "create a new token" do | |||
|
159 | assert User.find(2).rss_token | |||
|
160 | end | |||
|
161 | ||||
|
162 | should_set_the_flash_to /reset/ | |||
|
163 | should_redirect_to('my account') {'/my/account' } | |||
|
164 | end | |||
|
165 | end | |||
132 | end |
|
166 | end |
General Comments 0
You need to be logged in to leave comments.
Login now