The requested changes are too big and content was truncated. Show full diff
@@ -1,278 +1,278 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class AccountController < ApplicationController |
|
19 | 19 | helper :custom_fields |
|
20 | 20 | include CustomFieldsHelper |
|
21 | 21 | |
|
22 | 22 | # prevents login action to be filtered by check_if_login_required application scope filter |
|
23 | 23 | skip_before_filter :check_if_login_required, :only => [:login, :lost_password, :register, :activate] |
|
24 | 24 | |
|
25 | 25 | # Show user's account |
|
26 | 26 | def show |
|
27 | 27 | @user = User.active.find(params[:id]) |
|
28 | 28 | @custom_values = @user.custom_values |
|
29 | 29 | |
|
30 | 30 | # show only public projects and private projects that the logged in user is also a member of |
|
31 | 31 | @memberships = @user.memberships.select do |membership| |
|
32 | 32 | membership.project.is_public? || (User.current.member_of?(membership.project)) |
|
33 | 33 | end |
|
34 | 34 | |
|
35 | 35 | events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10) |
|
36 | 36 | @events_by_day = events.group_by(&:event_date) |
|
37 | 37 | |
|
38 | 38 | rescue ActiveRecord::RecordNotFound |
|
39 | 39 | render_404 |
|
40 | 40 | end |
|
41 | 41 | |
|
42 | 42 | # Login request and validation |
|
43 | 43 | def login |
|
44 | 44 | if request.get? |
|
45 | 45 | # Logout user |
|
46 | 46 | self.logged_user = nil |
|
47 | 47 | else |
|
48 | 48 | # Authenticate user |
|
49 | if using_open_id? && Setting.openid? | |
|
49 | if Setting.openid? && using_open_id? | |
|
50 | 50 | open_id_authenticate(params[:openid_url]) |
|
51 | 51 | else |
|
52 | 52 | password_authentication |
|
53 | 53 | end |
|
54 | 54 | end |
|
55 | 55 | end |
|
56 | 56 | |
|
57 | 57 | # Log out current user and redirect to welcome page |
|
58 | 58 | def logout |
|
59 | 59 | cookies.delete :autologin |
|
60 | 60 | Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin']) if User.current.logged? |
|
61 | 61 | self.logged_user = nil |
|
62 | 62 | redirect_to home_url |
|
63 | 63 | end |
|
64 | 64 | |
|
65 | 65 | # Enable user to choose a new password |
|
66 | 66 | def lost_password |
|
67 | 67 | redirect_to(home_url) && return unless Setting.lost_password? |
|
68 | 68 | if params[:token] |
|
69 | 69 | @token = Token.find_by_action_and_value("recovery", params[:token]) |
|
70 | 70 | redirect_to(home_url) && return unless @token and !@token.expired? |
|
71 | 71 | @user = @token.user |
|
72 | 72 | if request.post? |
|
73 | 73 | @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] |
|
74 | 74 | if @user.save |
|
75 | 75 | @token.destroy |
|
76 | 76 | flash[:notice] = l(:notice_account_password_updated) |
|
77 | 77 | redirect_to :action => 'login' |
|
78 | 78 | return |
|
79 | 79 | end |
|
80 | 80 | end |
|
81 | 81 | render :template => "account/password_recovery" |
|
82 | 82 | return |
|
83 | 83 | else |
|
84 | 84 | if request.post? |
|
85 | 85 | user = User.find_by_mail(params[:mail]) |
|
86 | 86 | # user not found in db |
|
87 | 87 | flash.now[:error] = l(:notice_account_unknown_email) and return unless user |
|
88 | 88 | # user uses an external authentification |
|
89 | 89 | flash.now[:error] = l(:notice_can_t_change_password) and return if user.auth_source_id |
|
90 | 90 | # create a new token for password recovery |
|
91 | 91 | token = Token.new(:user => user, :action => "recovery") |
|
92 | 92 | if token.save |
|
93 | 93 | Mailer.deliver_lost_password(token) |
|
94 | 94 | flash[:notice] = l(:notice_account_lost_email_sent) |
|
95 | 95 | redirect_to :action => 'login' |
|
96 | 96 | return |
|
97 | 97 | end |
|
98 | 98 | end |
|
99 | 99 | end |
|
100 | 100 | end |
|
101 | 101 | |
|
102 | 102 | # User self-registration |
|
103 | 103 | def register |
|
104 | 104 | redirect_to(home_url) && return unless Setting.self_registration? || session[:auth_source_registration] |
|
105 | 105 | if request.get? |
|
106 | 106 | session[:auth_source_registration] = nil |
|
107 | 107 | @user = User.new(:language => Setting.default_language) |
|
108 | 108 | else |
|
109 | 109 | @user = User.new(params[:user]) |
|
110 | 110 | @user.admin = false |
|
111 | 111 | @user.status = User::STATUS_REGISTERED |
|
112 | 112 | if session[:auth_source_registration] |
|
113 | 113 | @user.status = User::STATUS_ACTIVE |
|
114 | 114 | @user.login = session[:auth_source_registration][:login] |
|
115 | 115 | @user.auth_source_id = session[:auth_source_registration][:auth_source_id] |
|
116 | 116 | if @user.save |
|
117 | 117 | session[:auth_source_registration] = nil |
|
118 | 118 | self.logged_user = @user |
|
119 | 119 | flash[:notice] = l(:notice_account_activated) |
|
120 | 120 | redirect_to :controller => 'my', :action => 'account' |
|
121 | 121 | end |
|
122 | 122 | else |
|
123 | 123 | @user.login = params[:user][:login] |
|
124 | 124 | @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] |
|
125 | 125 | |
|
126 | 126 | case Setting.self_registration |
|
127 | 127 | when '1' |
|
128 | 128 | register_by_email_activation(@user) |
|
129 | 129 | when '3' |
|
130 | 130 | register_automatically(@user) |
|
131 | 131 | else |
|
132 | 132 | register_manually_by_administrator(@user) |
|
133 | 133 | end |
|
134 | 134 | end |
|
135 | 135 | end |
|
136 | 136 | end |
|
137 | 137 | |
|
138 | 138 | # Token based account activation |
|
139 | 139 | def activate |
|
140 | 140 | redirect_to(home_url) && return unless Setting.self_registration? && params[:token] |
|
141 | 141 | token = Token.find_by_action_and_value('register', params[:token]) |
|
142 | 142 | redirect_to(home_url) && return unless token and !token.expired? |
|
143 | 143 | user = token.user |
|
144 | 144 | redirect_to(home_url) && return unless user.status == User::STATUS_REGISTERED |
|
145 | 145 | user.status = User::STATUS_ACTIVE |
|
146 | 146 | if user.save |
|
147 | 147 | token.destroy |
|
148 | 148 | flash[:notice] = l(:notice_account_activated) |
|
149 | 149 | end |
|
150 | 150 | redirect_to :action => 'login' |
|
151 | 151 | end |
|
152 | 152 | |
|
153 | 153 | private |
|
154 | 154 | def logged_user=(user) |
|
155 | 155 | if user && user.is_a?(User) |
|
156 | 156 | User.current = user |
|
157 | 157 | session[:user_id] = user.id |
|
158 | 158 | else |
|
159 | 159 | User.current = User.anonymous |
|
160 | 160 | session[:user_id] = nil |
|
161 | 161 | end |
|
162 | 162 | end |
|
163 | 163 | |
|
164 | 164 | def password_authentication |
|
165 | 165 | user = User.try_to_login(params[:username], params[:password]) |
|
166 | 166 | if user.nil? |
|
167 | 167 | # Invalid credentials |
|
168 | 168 | flash.now[:error] = l(:notice_account_invalid_creditentials) |
|
169 | 169 | elsif user.new_record? |
|
170 | 170 | # Onthefly creation failed, display the registration form to fill/fix attributes |
|
171 | 171 | @user = user |
|
172 | 172 | session[:auth_source_registration] = {:login => user.login, :auth_source_id => user.auth_source_id } |
|
173 | 173 | render :action => 'register' |
|
174 | 174 | else |
|
175 | 175 | # Valid user |
|
176 | 176 | successful_authentication(user) |
|
177 | 177 | end |
|
178 | 178 | end |
|
179 | 179 | |
|
180 | 180 | |
|
181 | 181 | def open_id_authenticate(openid_url) |
|
182 | 182 | authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => signin_url) do |result, identity_url, registration| |
|
183 | 183 | if result.successful? |
|
184 | 184 | user = User.find_or_initialize_by_identity_url(identity_url) |
|
185 | 185 | if user.new_record? |
|
186 | 186 | # Self-registration off |
|
187 | 187 | redirect_to(home_url) && return unless Setting.self_registration? |
|
188 | 188 | |
|
189 | 189 | # Create on the fly |
|
190 | 190 | user.login = registration['nickname'] unless registration['nickname'].nil? |
|
191 | 191 | user.mail = registration['email'] unless registration['email'].nil? |
|
192 | 192 | user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil? |
|
193 | 193 | user.random_password |
|
194 | 194 | user.status = User::STATUS_REGISTERED |
|
195 | 195 | |
|
196 | 196 | case Setting.self_registration |
|
197 | 197 | when '1' |
|
198 | 198 | register_by_email_activation(user) do |
|
199 | 199 | onthefly_creation_failed(user, {:login => user.login, :identity_url => identity_url }) |
|
200 | 200 | end |
|
201 | 201 | when '3' |
|
202 | 202 | register_automatically(user) do |
|
203 | 203 | onthefly_creation_failed(user, {:login => user.login, :identity_url => identity_url }) |
|
204 | 204 | end |
|
205 | 205 | else |
|
206 | 206 | register_manually_by_administrator(user) do |
|
207 | 207 | onthefly_creation_failed(user, {:login => user.login, :identity_url => identity_url }) |
|
208 | 208 | end |
|
209 | 209 | end |
|
210 | 210 | else |
|
211 | 211 | # Existing record |
|
212 | 212 | successful_authentication(user) |
|
213 | 213 | end |
|
214 | 214 | end |
|
215 | 215 | end |
|
216 | 216 | end |
|
217 | 217 | |
|
218 | 218 | def successful_authentication(user) |
|
219 | 219 | # Valid user |
|
220 | 220 | self.logged_user = user |
|
221 | 221 | # generate a key and set cookie if autologin |
|
222 | 222 | if params[:autologin] && Setting.autologin? |
|
223 | 223 | token = Token.create(:user => user, :action => 'autologin') |
|
224 | 224 | cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now } |
|
225 | 225 | end |
|
226 | 226 | redirect_back_or_default :controller => 'my', :action => 'page' |
|
227 | 227 | end |
|
228 | 228 | |
|
229 | 229 | # Onthefly creation failed, display the registration form to fill/fix attributes |
|
230 | 230 | def onthefly_creation_failed(user, auth_source_options = { }) |
|
231 | 231 | @user = user |
|
232 | 232 | session[:auth_source_registration] = auth_source_options unless auth_source_options.empty? |
|
233 | 233 | render :action => 'register' |
|
234 | 234 | end |
|
235 | 235 | |
|
236 | 236 | # Register a user for email activation. |
|
237 | 237 | # |
|
238 | 238 | # Pass a block for behavior when a user fails to save |
|
239 | 239 | def register_by_email_activation(user, &block) |
|
240 | 240 | token = Token.new(:user => user, :action => "register") |
|
241 | 241 | if user.save and token.save |
|
242 | 242 | Mailer.deliver_register(token) |
|
243 | 243 | flash[:notice] = l(:notice_account_register_done) |
|
244 | 244 | redirect_to :action => 'login' |
|
245 | 245 | else |
|
246 | 246 | yield if block_given? |
|
247 | 247 | end |
|
248 | 248 | end |
|
249 | 249 | |
|
250 | 250 | # Automatically register a user |
|
251 | 251 | # |
|
252 | 252 | # Pass a block for behavior when a user fails to save |
|
253 | 253 | def register_automatically(user, &block) |
|
254 | 254 | # Automatic activation |
|
255 | 255 | user.status = User::STATUS_ACTIVE |
|
256 | 256 | if user.save |
|
257 | 257 | self.logged_user = user |
|
258 | 258 | flash[:notice] = l(:notice_account_activated) |
|
259 | 259 | redirect_to :controller => 'my', :action => 'account' |
|
260 | 260 | else |
|
261 | 261 | yield if block_given? |
|
262 | 262 | end |
|
263 | 263 | end |
|
264 | 264 | |
|
265 | 265 | # Manual activation by the administrator |
|
266 | 266 | # |
|
267 | 267 | # Pass a block for behavior when a user fails to save |
|
268 | 268 | def register_manually_by_administrator(user, &block) |
|
269 | 269 | if user.save |
|
270 | 270 | # Sends an email to the administrators |
|
271 | 271 | Mailer.deliver_account_activation_request(user) |
|
272 | 272 | flash[:notice] = l(:notice_account_pending) |
|
273 | 273 | redirect_to :action => 'login' |
|
274 | 274 | else |
|
275 | 275 | yield if block_given? |
|
276 | 276 | end |
|
277 | 277 | end |
|
278 | 278 | end |
@@ -1,164 +1,168 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class Setting < ActiveRecord::Base |
|
19 | 19 | |
|
20 | 20 | DATE_FORMATS = [ |
|
21 | 21 | '%Y-%m-%d', |
|
22 | 22 | '%d/%m/%Y', |
|
23 | 23 | '%d.%m.%Y', |
|
24 | 24 | '%d-%m-%Y', |
|
25 | 25 | '%m/%d/%Y', |
|
26 | 26 | '%d %b %Y', |
|
27 | 27 | '%d %B %Y', |
|
28 | 28 | '%b %d, %Y', |
|
29 | 29 | '%B %d, %Y' |
|
30 | 30 | ] |
|
31 | 31 | |
|
32 | 32 | TIME_FORMATS = [ |
|
33 | 33 | '%H:%M', |
|
34 | 34 | '%I:%M %p' |
|
35 | 35 | ] |
|
36 | 36 | |
|
37 | 37 | ENCODINGS = %w(US-ASCII |
|
38 | 38 | windows-1250 |
|
39 | 39 | windows-1251 |
|
40 | 40 | windows-1252 |
|
41 | 41 | windows-1253 |
|
42 | 42 | windows-1254 |
|
43 | 43 | windows-1255 |
|
44 | 44 | windows-1256 |
|
45 | 45 | windows-1257 |
|
46 | 46 | windows-1258 |
|
47 | 47 | windows-31j |
|
48 | 48 | ISO-2022-JP |
|
49 | 49 | ISO-2022-KR |
|
50 | 50 | ISO-8859-1 |
|
51 | 51 | ISO-8859-2 |
|
52 | 52 | ISO-8859-3 |
|
53 | 53 | ISO-8859-4 |
|
54 | 54 | ISO-8859-5 |
|
55 | 55 | ISO-8859-6 |
|
56 | 56 | ISO-8859-7 |
|
57 | 57 | ISO-8859-8 |
|
58 | 58 | ISO-8859-9 |
|
59 | 59 | ISO-8859-13 |
|
60 | 60 | ISO-8859-15 |
|
61 | 61 | KOI8-R |
|
62 | 62 | UTF-8 |
|
63 | 63 | UTF-16 |
|
64 | 64 | UTF-16BE |
|
65 | 65 | UTF-16LE |
|
66 | 66 | EUC-JP |
|
67 | 67 | Shift_JIS |
|
68 | 68 | GB18030 |
|
69 | 69 | GBK |
|
70 | 70 | ISCII91 |
|
71 | 71 | EUC-KR |
|
72 | 72 | Big5 |
|
73 | 73 | Big5-HKSCS |
|
74 | 74 | TIS-620) |
|
75 | 75 | |
|
76 | 76 | cattr_accessor :available_settings |
|
77 | 77 | @@available_settings = YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml")) |
|
78 | 78 | Redmine::Plugin.all.each do |plugin| |
|
79 | 79 | next unless plugin.settings |
|
80 | 80 | @@available_settings["plugin_#{plugin.id}"] = {'default' => plugin.settings[:default], 'serialized' => true} |
|
81 | 81 | end |
|
82 | 82 | |
|
83 | 83 | validates_uniqueness_of :name |
|
84 | 84 | validates_inclusion_of :name, :in => @@available_settings.keys |
|
85 | 85 | validates_numericality_of :value, :only_integer => true, :if => Proc.new { |setting| @@available_settings[setting.name]['format'] == 'int' } |
|
86 | 86 | |
|
87 | 87 | # Hash used to cache setting values |
|
88 | 88 | @cached_settings = {} |
|
89 | 89 | @cached_cleared_on = Time.now |
|
90 | 90 | |
|
91 | 91 | def value |
|
92 | 92 | v = read_attribute(:value) |
|
93 | 93 | # Unserialize serialized settings |
|
94 | 94 | v = YAML::load(v) if @@available_settings[name]['serialized'] && v.is_a?(String) |
|
95 | 95 | v = v.to_sym if @@available_settings[name]['format'] == 'symbol' && !v.blank? |
|
96 | 96 | v |
|
97 | 97 | end |
|
98 | 98 | |
|
99 | 99 | def value=(v) |
|
100 | 100 | v = v.to_yaml if v && @@available_settings[name]['serialized'] |
|
101 | 101 | write_attribute(:value, v.to_s) |
|
102 | 102 | end |
|
103 | 103 | |
|
104 | 104 | # Returns the value of the setting named name |
|
105 | 105 | def self.[](name) |
|
106 | 106 | v = @cached_settings[name] |
|
107 | 107 | v ? v : (@cached_settings[name] = find_or_default(name).value) |
|
108 | 108 | end |
|
109 | 109 | |
|
110 | 110 | def self.[]=(name, v) |
|
111 | 111 | setting = find_or_default(name) |
|
112 | 112 | setting.value = (v ? v : "") |
|
113 | 113 | @cached_settings[name] = nil |
|
114 | 114 | setting.save |
|
115 | 115 | setting.value |
|
116 | 116 | end |
|
117 | 117 | |
|
118 | 118 | # Defines getter and setter for each setting |
|
119 | 119 | # Then setting values can be read using: Setting.some_setting_name |
|
120 | 120 | # or set using Setting.some_setting_name = "some value" |
|
121 | 121 | @@available_settings.each do |name, params| |
|
122 | 122 | src = <<-END_SRC |
|
123 | 123 | def self.#{name} |
|
124 | 124 | self[:#{name}] |
|
125 | 125 | end |
|
126 | 126 | |
|
127 | 127 | def self.#{name}? |
|
128 | 128 | self[:#{name}].to_i > 0 |
|
129 | 129 | end |
|
130 | 130 | |
|
131 | 131 | def self.#{name}=(value) |
|
132 | 132 | self[:#{name}] = value |
|
133 | 133 | end |
|
134 | 134 | END_SRC |
|
135 | 135 | class_eval src, __FILE__, __LINE__ |
|
136 | 136 | end |
|
137 | 137 | |
|
138 | 138 | # Helper that returns an array based on per_page_options setting |
|
139 | 139 | def self.per_page_options_array |
|
140 | 140 | per_page_options.split(%r{[\s,]}).collect(&:to_i).select {|n| n > 0}.sort |
|
141 | 141 | end |
|
142 | 142 | |
|
143 | def self.openid? | |
|
144 | Object.const_defined?(:OpenID) && self['openid'].to_s == '1' | |
|
145 | end | |
|
146 | ||
|
143 | 147 | # Checks if settings have changed since the values were read |
|
144 | 148 | # and clears the cache hash if it's the case |
|
145 | 149 | # Called once per request |
|
146 | 150 | def self.check_cache |
|
147 | 151 | settings_updated_on = Setting.maximum(:updated_on) |
|
148 | 152 | if settings_updated_on && @cached_cleared_on <= settings_updated_on |
|
149 | 153 | @cached_settings.clear |
|
150 | 154 | @cached_cleared_on = Time.now |
|
151 | 155 | logger.info "Settings cache cleared." if logger |
|
152 | 156 | end |
|
153 | 157 | end |
|
154 | 158 | |
|
155 | 159 | private |
|
156 | 160 | # Returns the Setting instance for the setting named name |
|
157 | 161 | # (record found in database or new record with default value) |
|
158 | 162 | def self.find_or_default(name) |
|
159 | 163 | name = name.to_s |
|
160 | 164 | raise "There's no setting named #{name}" unless @@available_settings.has_key?(name) |
|
161 | 165 | setting = find_by_name(name) |
|
162 | 166 | setting ||= new(:name => name, :value => @@available_settings[name]['default']) if @@available_settings.has_key? name |
|
163 | 167 | end |
|
164 | 168 | end |
@@ -1,30 +1,30 | |||
|
1 | 1 | <% form_tag({:action => 'edit', :tab => 'authentication'}) do %> |
|
2 | 2 | |
|
3 | 3 | <div class="box tabular settings"> |
|
4 | 4 | <p><label><%= l(:setting_login_required) %></label> |
|
5 | 5 | <%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p> |
|
6 | 6 | |
|
7 | 7 | <p><label><%= l(:setting_autologin) %></label> |
|
8 | 8 | <%= select_tag 'settings[autologin]', options_for_select( [[l(:label_disabled), "0"]] + [1, 7, 30, 365].collect{|days| [lwr(:actionview_datehelper_time_in_words_day, days), days.to_s]}, Setting.autologin) %></p> |
|
9 | 9 | |
|
10 | 10 | <p><label><%= l(:setting_self_registration) %></label> |
|
11 | 11 | <%= select_tag 'settings[self_registration]', |
|
12 | 12 | options_for_select( [[l(:label_disabled), "0"], |
|
13 | 13 | [l(:label_registration_activation_by_email), "1"], |
|
14 | 14 | [l(:label_registration_manual_activation), "2"], |
|
15 | 15 | [l(:label_registration_automatic_activation), "3"] |
|
16 | 16 | ], Setting.self_registration ) %></p> |
|
17 | 17 | |
|
18 | 18 | <p><label><%= l(:label_password_lost) %></label> |
|
19 | 19 | <%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p> |
|
20 | 20 | |
|
21 | 21 | <p><label><%= l(:setting_openid) %></label> |
|
22 | <%= check_box_tag 'settings[openid]', 1, Setting.openid? %><%= hidden_field_tag 'settings[openid]', 0 %></p> | |
|
22 | <%= check_box_tag 'settings[openid]', 1, Setting.openid?, :disabled => !Object.const_defined?(:OpenID) %><%= hidden_field_tag 'settings[openid]', 0 %></p> | |
|
23 | 23 | </div> |
|
24 | 24 | |
|
25 | 25 | <div style="float:right;"> |
|
26 | 26 | <%= link_to l(:label_ldap_authentication), :controller => 'auth_sources', :action => 'list' %> |
|
27 | 27 | </div> |
|
28 | 28 | |
|
29 | 29 | <%= submit_tag l(:button_save) %> |
|
30 | 30 | <% end %> |
@@ -1,154 +1,161 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | require 'account_controller' |
|
20 | 20 | |
|
21 | 21 | # Re-raise errors caught by the controller. |
|
22 | 22 | class AccountController; def rescue_action(e) raise e end; end |
|
23 | 23 | |
|
24 | 24 | class AccountControllerTest < Test::Unit::TestCase |
|
25 | 25 | fixtures :users, :roles |
|
26 | 26 | |
|
27 | 27 | def setup |
|
28 | 28 | @controller = AccountController.new |
|
29 | 29 | @request = ActionController::TestRequest.new |
|
30 | 30 | @response = ActionController::TestResponse.new |
|
31 | 31 | User.current = nil |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | def test_show |
|
35 | 35 | get :show, :id => 2 |
|
36 | 36 | assert_response :success |
|
37 | 37 | assert_template 'show' |
|
38 | 38 | assert_not_nil assigns(:user) |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | def test_show_inactive |
|
42 | 42 | get :show, :id => 5 |
|
43 | 43 | assert_response 404 |
|
44 | 44 | assert_nil assigns(:user) |
|
45 | 45 | end |
|
46 | 46 | |
|
47 | 47 | def test_login_should_redirect_to_back_url_param |
|
48 | 48 | # request.uri is "test.host" in test environment |
|
49 | 49 | post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http%3A%2F%2Ftest.host%2Fissues%2Fshow%2F1' |
|
50 | 50 | assert_redirected_to '/issues/show/1' |
|
51 | 51 | end |
|
52 | 52 | |
|
53 | 53 | def test_login_should_not_redirect_to_another_host |
|
54 | 54 | post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http%3A%2F%2Ftest.foo%2Ffake' |
|
55 | 55 | assert_redirected_to '/my/page' |
|
56 | 56 | end |
|
57 | 57 | |
|
58 | 58 | def test_login_with_wrong_password |
|
59 | 59 | post :login, :username => 'admin', :password => 'bad' |
|
60 | 60 | assert_response :success |
|
61 | 61 | assert_template 'login' |
|
62 | 62 | assert_tag 'div', |
|
63 | 63 | :attributes => { :class => "flash error" }, |
|
64 | 64 | :content => /Invalid user or password/ |
|
65 | 65 | end |
|
66 | 66 | |
|
67 | if Object.const_defined?(:OpenID) | |
|
68 | ||
|
67 | 69 | def test_login_with_openid_for_existing_user |
|
68 | 70 | Setting.self_registration = '3' |
|
69 | 71 | Setting.openid = '1' |
|
70 | 72 | existing_user = User.new(:firstname => 'Cool', |
|
71 | 73 | :lastname => 'User', |
|
72 | 74 | :mail => 'user@somedomain.com', |
|
73 | 75 | :identity_url => 'http://openid.example.com/good_user') |
|
74 | 76 | existing_user.login = 'cool_user' |
|
75 | 77 | assert existing_user.save! |
|
76 | 78 | |
|
77 | 79 | post :login, :openid_url => existing_user.identity_url |
|
78 | 80 | assert_redirected_to 'my/page' |
|
79 | 81 | end |
|
80 | 82 | |
|
81 | 83 | def test_login_with_openid_with_new_user_created |
|
82 | 84 | Setting.self_registration = '3' |
|
83 | 85 | Setting.openid = '1' |
|
84 | 86 | post :login, :openid_url => 'http://openid.example.com/good_user' |
|
85 | 87 | assert_redirected_to 'my/account' |
|
86 | 88 | user = User.find_by_login('cool_user') |
|
87 | 89 | assert user |
|
88 | 90 | assert_equal 'Cool', user.firstname |
|
89 | 91 | assert_equal 'User', user.lastname |
|
90 | 92 | end |
|
91 | 93 | |
|
92 | 94 | def test_login_with_openid_with_new_user_and_self_registration_off |
|
93 | 95 | Setting.self_registration = '0' |
|
94 | 96 | Setting.openid = '1' |
|
95 | 97 | post :login, :openid_url => 'http://openid.example.com/good_user' |
|
96 | 98 | assert_redirected_to home_url |
|
97 | 99 | user = User.find_by_login('cool_user') |
|
98 | 100 | assert ! user |
|
99 | 101 | end |
|
100 | 102 | |
|
101 | 103 | def test_login_with_openid_with_new_user_created_with_email_activation_should_have_a_token |
|
102 | 104 | Setting.self_registration = '1' |
|
103 | 105 | Setting.openid = '1' |
|
104 | 106 | post :login, :openid_url => 'http://openid.example.com/good_user' |
|
105 | 107 | assert_redirected_to 'login' |
|
106 | 108 | user = User.find_by_login('cool_user') |
|
107 | 109 | assert user |
|
108 | 110 | |
|
109 | 111 | token = Token.find_by_user_id_and_action(user.id, 'register') |
|
110 | 112 | assert token |
|
111 | 113 | end |
|
112 | 114 | |
|
113 | 115 | def test_login_with_openid_with_new_user_created_with_manual_activation |
|
114 | 116 | Setting.self_registration = '2' |
|
115 | 117 | Setting.openid = '1' |
|
116 | 118 | post :login, :openid_url => 'http://openid.example.com/good_user' |
|
117 | 119 | assert_redirected_to 'login' |
|
118 | 120 | user = User.find_by_login('cool_user') |
|
119 | 121 | assert user |
|
120 | 122 | assert_equal User::STATUS_REGISTERED, user.status |
|
121 | 123 | end |
|
122 | 124 | |
|
123 | 125 | def test_login_with_openid_with_new_user_with_conflict_should_register |
|
124 | 126 | Setting.self_registration = '3' |
|
125 | 127 | Setting.openid = '1' |
|
126 | 128 | existing_user = User.new(:firstname => 'Cool', :lastname => 'User', :mail => 'user@somedomain.com') |
|
127 | 129 | existing_user.login = 'cool_user' |
|
128 | 130 | assert existing_user.save! |
|
129 | 131 | |
|
130 | 132 | post :login, :openid_url => 'http://openid.example.com/good_user' |
|
131 | 133 | assert_response :success |
|
132 | 134 | assert_template 'register' |
|
133 | 135 | assert assigns(:user) |
|
134 | 136 | assert_equal 'http://openid.example.com/good_user', assigns(:user)[:identity_url] |
|
135 | 137 | end |
|
136 | 138 | |
|
139 | else | |
|
140 | puts "Skipping openid tests." | |
|
141 | end | |
|
142 | ||
|
143 | ||
|
137 | 144 | def test_autologin |
|
138 | 145 | Setting.autologin = "7" |
|
139 | 146 | Token.delete_all |
|
140 | 147 | post :login, :username => 'admin', :password => 'admin', :autologin => 1 |
|
141 | 148 | assert_redirected_to 'my/page' |
|
142 | 149 | token = Token.find :first |
|
143 | 150 | assert_not_nil token |
|
144 | 151 | assert_equal User.find_by_login('admin'), token.user |
|
145 | 152 | assert_equal 'autologin', token.action |
|
146 | 153 | end |
|
147 | 154 | |
|
148 | 155 | def test_logout |
|
149 | 156 | @request.session[:user_id] = 2 |
|
150 | 157 | get :logout |
|
151 | 158 | assert_redirected_to '' |
|
152 | 159 | assert_nil @request.session[:user_id] |
|
153 | 160 | end |
|
154 | 161 | end |
@@ -1,206 +1,212 | |||
|
1 | # redMine - project management software | |
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |
|
3 | # | |
|
4 | # This program is free software; you can redistribute it and/or | |
|
5 | # modify it under the terms of the GNU General Public License | |
|
6 | # as published by the Free Software Foundation; either version 2 | |
|
7 | # of the License, or (at your option) any later version. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
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 | |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
|
17 | ||
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
|
19 | ||
|
20 | class UserTest < Test::Unit::TestCase | |
|
21 | fixtures :users, :members, :projects | |
|
22 | ||
|
23 | def setup | |
|
24 | @admin = User.find(1) | |
|
25 | @jsmith = User.find(2) | |
|
26 | @dlopper = User.find(3) | |
|
27 | end | |
|
28 | ||
|
29 | def test_truth | |
|
30 | assert_kind_of User, @jsmith | |
|
31 | end | |
|
1 | # redMine - project management software | |
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |
|
3 | # | |
|
4 | # This program is free software; you can redistribute it and/or | |
|
5 | # modify it under the terms of the GNU General Public License | |
|
6 | # as published by the Free Software Foundation; either version 2 | |
|
7 | # of the License, or (at your option) any later version. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
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 | |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
|
17 | ||
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
|
19 | ||
|
20 | class UserTest < Test::Unit::TestCase | |
|
21 | fixtures :users, :members, :projects | |
|
22 | ||
|
23 | def setup | |
|
24 | @admin = User.find(1) | |
|
25 | @jsmith = User.find(2) | |
|
26 | @dlopper = User.find(3) | |
|
27 | end | |
|
28 | ||
|
29 | def test_truth | |
|
30 | assert_kind_of User, @jsmith | |
|
31 | end | |
|
32 | 32 | |
|
33 | 33 | def test_create |
|
34 | 34 | user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo") |
|
35 | 35 | |
|
36 | 36 | user.login = "jsmith" |
|
37 | 37 | user.password, user.password_confirmation = "password", "password" |
|
38 | 38 | # login uniqueness |
|
39 | 39 | assert !user.save |
|
40 | 40 | assert_equal 1, user.errors.count |
|
41 | 41 | |
|
42 | 42 | user.login = "newuser" |
|
43 | 43 | user.password, user.password_confirmation = "passwd", "password" |
|
44 | 44 | # password confirmation |
|
45 | 45 | assert !user.save |
|
46 | 46 | assert_equal 1, user.errors.count |
|
47 | 47 | |
|
48 | 48 | user.password, user.password_confirmation = "password", "password" |
|
49 | 49 | assert user.save |
|
50 | end | |
|
51 | ||
|
52 | def test_mail_uniqueness_should_not_be_case_sensitive | |
|
53 | u = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo") | |
|
54 | u.login = 'newuser1' | |
|
55 | u.password, u.password_confirmation = "password", "password" | |
|
56 | assert u.save | |
|
57 | ||
|
58 | u = User.new(:firstname => "new", :lastname => "user", :mail => "newUser@Somenet.foo") | |
|
59 | u.login = 'newuser2' | |
|
60 | u.password, u.password_confirmation = "password", "password" | |
|
61 | assert !u.save | |
|
62 | assert_equal 'activerecord_error_taken', u.errors.on(:mail) | |
|
63 | end | |
|
64 | ||
|
65 | def test_update | |
|
66 | assert_equal "admin", @admin.login | |
|
67 | @admin.login = "john" | |
|
68 | assert @admin.save, @admin.errors.full_messages.join("; ") | |
|
69 | @admin.reload | |
|
70 | assert_equal "john", @admin.login | |
|
71 | end | |
|
72 | ||
|
73 | def test_destroy | |
|
74 | User.find(2).destroy | |
|
75 | assert_nil User.find_by_id(2) | |
|
76 | assert Member.find_all_by_user_id(2).empty? | |
|
77 | end | |
|
78 | ||
|
79 | def test_validate | |
|
80 | @admin.login = "" | |
|
81 | assert !@admin.save | |
|
82 | assert_equal 1, @admin.errors.count | |
|
83 | end | |
|
84 | ||
|
85 | def test_password | |
|
86 | user = User.try_to_login("admin", "admin") | |
|
87 | assert_kind_of User, user | |
|
88 | assert_equal "admin", user.login | |
|
89 | user.password = "hello" | |
|
90 | assert user.save | |
|
91 | ||
|
92 | user = User.try_to_login("admin", "hello") | |
|
93 | assert_kind_of User, user | |
|
94 | assert_equal "admin", user.login | |
|
95 | assert_equal User.hash_password("hello"), user.hashed_password | |
|
96 | end | |
|
97 | ||
|
98 | def test_name_format | |
|
99 | assert_equal 'Smith, John', @jsmith.name(:lastname_coma_firstname) | |
|
100 | Setting.user_format = :firstname_lastname | |
|
101 | assert_equal 'John Smith', @jsmith.reload.name | |
|
102 | Setting.user_format = :username | |
|
103 | assert_equal 'jsmith', @jsmith.reload.name | |
|
104 | end | |
|
105 | ||
|
106 | def test_lock | |
|
107 | user = User.try_to_login("jsmith", "jsmith") | |
|
108 | assert_equal @jsmith, user | |
|
109 | ||
|
110 | @jsmith.status = User::STATUS_LOCKED | |
|
111 | assert @jsmith.save | |
|
112 | ||
|
113 | user = User.try_to_login("jsmith", "jsmith") | |
|
114 | assert_equal nil, user | |
|
115 | end | |
|
116 | ||
|
117 | def test_create_anonymous | |
|
118 | AnonymousUser.delete_all | |
|
119 | anon = User.anonymous | |
|
120 | assert !anon.new_record? | |
|
121 | assert_kind_of AnonymousUser, anon | |
|
122 | end | |
|
123 | ||
|
124 | def test_rss_key | |
|
125 | assert_nil @jsmith.rss_token | |
|
126 | key = @jsmith.rss_key | |
|
127 | assert_equal 40, key.length | |
|
128 | ||
|
129 | @jsmith.reload | |
|
130 | assert_equal key, @jsmith.rss_key | |
|
131 | end | |
|
132 | ||
|
133 | def test_role_for_project | |
|
134 | # user with a role | |
|
135 | role = @jsmith.role_for_project(Project.find(1)) | |
|
136 | assert_kind_of Role, role | |
|
137 | assert_equal "Manager", role.name | |
|
138 | ||
|
139 | # user with no role | |
|
140 | assert !@dlopper.role_for_project(Project.find(2)).member? | |
|
141 | end | |
|
142 | ||
|
143 | def test_mail_notification_all | |
|
144 | @jsmith.mail_notification = true | |
|
145 | @jsmith.notified_project_ids = [] | |
|
146 | @jsmith.save | |
|
147 | @jsmith.reload | |
|
148 | assert @jsmith.projects.first.recipients.include?(@jsmith.mail) | |
|
149 | end | |
|
150 | ||
|
151 | def test_mail_notification_selected | |
|
152 | @jsmith.mail_notification = false | |
|
153 | @jsmith.notified_project_ids = [1] | |
|
154 | @jsmith.save | |
|
155 | @jsmith.reload | |
|
156 | assert Project.find(1).recipients.include?(@jsmith.mail) | |
|
157 | end | |
|
158 | ||
|
159 | def test_mail_notification_none | |
|
160 | @jsmith.mail_notification = false | |
|
161 | @jsmith.notified_project_ids = [] | |
|
162 | @jsmith.save | |
|
163 | @jsmith.reload | |
|
164 | assert !@jsmith.projects.first.recipients.include?(@jsmith.mail) | |
|
165 | end | |
|
166 | ||
|
167 | def test_comments_sorting_preference | |
|
168 | assert !@jsmith.wants_comments_in_reverse_order? | |
|
169 | @jsmith.pref.comments_sorting = 'asc' | |
|
170 | assert !@jsmith.wants_comments_in_reverse_order? | |
|
171 | @jsmith.pref.comments_sorting = 'desc' | |
|
172 | assert @jsmith.wants_comments_in_reverse_order? | |
|
173 | end | |
|
174 | ||
|
175 | def test_find_by_mail_should_be_case_insensitive | |
|
176 | u = User.find_by_mail('JSmith@somenet.foo') | |
|
177 | assert_not_nil u | |
|
178 | assert_equal 'jsmith@somenet.foo', u.mail | |
|
179 | end | |
|
180 | ||
|
181 | def test_random_password | |
|
182 | u = User.new | |
|
183 | u.random_password | |
|
184 | assert !u.password.blank? | |
|
185 | assert !u.password_confirmation.blank? | |
|
186 | end | |
|
187 | ||
|
188 | def test_setting_identity_url | |
|
189 | normalized_open_id_url = 'http://example.com/' | |
|
190 | u = User.new( :identity_url => 'http://example.com/' ) | |
|
191 | assert_equal normalized_open_id_url, u.identity_url | |
|
192 | end | |
|
193 | ||
|
194 | def test_setting_identity_url_without_trailing_slash | |
|
195 | normalized_open_id_url = 'http://example.com/' | |
|
196 | u = User.new( :identity_url => 'http://example.com' ) | |
|
197 | assert_equal normalized_open_id_url, u.identity_url | |
|
198 | end | |
|
199 | ||
|
200 | def test_setting_identity_url_without_protocol | |
|
201 | normalized_open_id_url = 'http://example.com/' | |
|
202 | u = User.new( :identity_url => 'example.com' ) | |
|
203 | assert_equal normalized_open_id_url, u.identity_url | |
|
204 | end | |
|
205 | ||
|
206 | end | |
|
50 | end | |
|
51 | ||
|
52 | def test_mail_uniqueness_should_not_be_case_sensitive | |
|
53 | u = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo") | |
|
54 | u.login = 'newuser1' | |
|
55 | u.password, u.password_confirmation = "password", "password" | |
|
56 | assert u.save | |
|
57 | ||
|
58 | u = User.new(:firstname => "new", :lastname => "user", :mail => "newUser@Somenet.foo") | |
|
59 | u.login = 'newuser2' | |
|
60 | u.password, u.password_confirmation = "password", "password" | |
|
61 | assert !u.save | |
|
62 | assert_equal 'activerecord_error_taken', u.errors.on(:mail) | |
|
63 | end | |
|
64 | ||
|
65 | def test_update | |
|
66 | assert_equal "admin", @admin.login | |
|
67 | @admin.login = "john" | |
|
68 | assert @admin.save, @admin.errors.full_messages.join("; ") | |
|
69 | @admin.reload | |
|
70 | assert_equal "john", @admin.login | |
|
71 | end | |
|
72 | ||
|
73 | def test_destroy | |
|
74 | User.find(2).destroy | |
|
75 | assert_nil User.find_by_id(2) | |
|
76 | assert Member.find_all_by_user_id(2).empty? | |
|
77 | end | |
|
78 | ||
|
79 | def test_validate | |
|
80 | @admin.login = "" | |
|
81 | assert !@admin.save | |
|
82 | assert_equal 1, @admin.errors.count | |
|
83 | end | |
|
84 | ||
|
85 | def test_password | |
|
86 | user = User.try_to_login("admin", "admin") | |
|
87 | assert_kind_of User, user | |
|
88 | assert_equal "admin", user.login | |
|
89 | user.password = "hello" | |
|
90 | assert user.save | |
|
91 | ||
|
92 | user = User.try_to_login("admin", "hello") | |
|
93 | assert_kind_of User, user | |
|
94 | assert_equal "admin", user.login | |
|
95 | assert_equal User.hash_password("hello"), user.hashed_password | |
|
96 | end | |
|
97 | ||
|
98 | def test_name_format | |
|
99 | assert_equal 'Smith, John', @jsmith.name(:lastname_coma_firstname) | |
|
100 | Setting.user_format = :firstname_lastname | |
|
101 | assert_equal 'John Smith', @jsmith.reload.name | |
|
102 | Setting.user_format = :username | |
|
103 | assert_equal 'jsmith', @jsmith.reload.name | |
|
104 | end | |
|
105 | ||
|
106 | def test_lock | |
|
107 | user = User.try_to_login("jsmith", "jsmith") | |
|
108 | assert_equal @jsmith, user | |
|
109 | ||
|
110 | @jsmith.status = User::STATUS_LOCKED | |
|
111 | assert @jsmith.save | |
|
112 | ||
|
113 | user = User.try_to_login("jsmith", "jsmith") | |
|
114 | assert_equal nil, user | |
|
115 | end | |
|
116 | ||
|
117 | def test_create_anonymous | |
|
118 | AnonymousUser.delete_all | |
|
119 | anon = User.anonymous | |
|
120 | assert !anon.new_record? | |
|
121 | assert_kind_of AnonymousUser, anon | |
|
122 | end | |
|
123 | ||
|
124 | def test_rss_key | |
|
125 | assert_nil @jsmith.rss_token | |
|
126 | key = @jsmith.rss_key | |
|
127 | assert_equal 40, key.length | |
|
128 | ||
|
129 | @jsmith.reload | |
|
130 | assert_equal key, @jsmith.rss_key | |
|
131 | end | |
|
132 | ||
|
133 | def test_role_for_project | |
|
134 | # user with a role | |
|
135 | role = @jsmith.role_for_project(Project.find(1)) | |
|
136 | assert_kind_of Role, role | |
|
137 | assert_equal "Manager", role.name | |
|
138 | ||
|
139 | # user with no role | |
|
140 | assert !@dlopper.role_for_project(Project.find(2)).member? | |
|
141 | end | |
|
142 | ||
|
143 | def test_mail_notification_all | |
|
144 | @jsmith.mail_notification = true | |
|
145 | @jsmith.notified_project_ids = [] | |
|
146 | @jsmith.save | |
|
147 | @jsmith.reload | |
|
148 | assert @jsmith.projects.first.recipients.include?(@jsmith.mail) | |
|
149 | end | |
|
150 | ||
|
151 | def test_mail_notification_selected | |
|
152 | @jsmith.mail_notification = false | |
|
153 | @jsmith.notified_project_ids = [1] | |
|
154 | @jsmith.save | |
|
155 | @jsmith.reload | |
|
156 | assert Project.find(1).recipients.include?(@jsmith.mail) | |
|
157 | end | |
|
158 | ||
|
159 | def test_mail_notification_none | |
|
160 | @jsmith.mail_notification = false | |
|
161 | @jsmith.notified_project_ids = [] | |
|
162 | @jsmith.save | |
|
163 | @jsmith.reload | |
|
164 | assert !@jsmith.projects.first.recipients.include?(@jsmith.mail) | |
|
165 | end | |
|
166 | ||
|
167 | def test_comments_sorting_preference | |
|
168 | assert !@jsmith.wants_comments_in_reverse_order? | |
|
169 | @jsmith.pref.comments_sorting = 'asc' | |
|
170 | assert !@jsmith.wants_comments_in_reverse_order? | |
|
171 | @jsmith.pref.comments_sorting = 'desc' | |
|
172 | assert @jsmith.wants_comments_in_reverse_order? | |
|
173 | end | |
|
174 | ||
|
175 | def test_find_by_mail_should_be_case_insensitive | |
|
176 | u = User.find_by_mail('JSmith@somenet.foo') | |
|
177 | assert_not_nil u | |
|
178 | assert_equal 'jsmith@somenet.foo', u.mail | |
|
179 | end | |
|
180 | ||
|
181 | def test_random_password | |
|
182 | u = User.new | |
|
183 | u.random_password | |
|
184 | assert !u.password.blank? | |
|
185 | assert !u.password_confirmation.blank? | |
|
186 | end | |
|
187 | ||
|
188 | if Object.const_defined?(:OpenID) | |
|
189 | ||
|
190 | def test_setting_identity_url | |
|
191 | normalized_open_id_url = 'http://example.com/' | |
|
192 | u = User.new( :identity_url => 'http://example.com/' ) | |
|
193 | assert_equal normalized_open_id_url, u.identity_url | |
|
194 | end | |
|
195 | ||
|
196 | def test_setting_identity_url_without_trailing_slash | |
|
197 | normalized_open_id_url = 'http://example.com/' | |
|
198 | u = User.new( :identity_url => 'http://example.com' ) | |
|
199 | assert_equal normalized_open_id_url, u.identity_url | |
|
200 | end | |
|
201 | ||
|
202 | def test_setting_identity_url_without_protocol | |
|
203 | normalized_open_id_url = 'http://example.com/' | |
|
204 | u = User.new( :identity_url => 'example.com' ) | |
|
205 | assert_equal normalized_open_id_url, u.identity_url | |
|
206 | end | |
|
207 | ||
|
208 | else | |
|
209 | puts "Skipping openid tests." | |
|
210 | end | |
|
211 | ||
|
212 | end |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed, binary diff hidden |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (750 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (584 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (854 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (1785 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (523 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (516 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (553 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (1544 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
General Comments 0
You need to be logged in to leave comments.
Login now