community_engine 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,9 @@
1
1
  #hd
2
+ - if !configatron.community_locale
3
+ %div
4
+ %a{:href=>url_for(:subdomain => 'ru', :only_path => false ), :title=>"#{configatron.community_locale} russian translation"}= "rus"
5
+ %a{:href=>url_for(:subdomain => 'en', :only_path =>false), :title=>"english translation" }= "eng"
6
+
2
7
  %h1
3
8
  %a{:href=>home_url, :title=>"#{configatron.community_name}"}= configatron.community_name
4
9
  - if logged_in?
@@ -10,6 +10,6 @@ xml.rss "version" => "2.0",
10
10
  xml.ttl "60"
11
11
  xml.tag! "atom:link", :rel => 'search', :type => 'application/opensearchdescription+xml', :href => "http://#{request.host_with_port}/open_search.xml"
12
12
  xml.description @topic.body
13
- render :partial => "sb_posts/post.xml", :collection => @topic.sb_posts, :locals => {:xm => xml}
13
+ render :partial => "sb_posts/post", :collection => @topic.sb_posts, :locals => {:xm => xml}, :formats => [:xml]
14
14
  end
15
15
  end
@@ -52,7 +52,7 @@
52
52
  -box do
53
53
  %h3= :tags.l
54
54
  #user_tags
55
- = text_field_tag 'tag_list', @user.tag_list, {:autocomplete => "off"}
55
+ = text_field_tag 'tag_list', @user.tag_list.join(", "), {:autocomplete => "off"}
56
56
  #tag_list_auto_complete.auto_complete
57
57
  -content_for :end_javascript do
58
58
  = auto_complete_field 'tag_list', {:url => { :controller => "tags", :action => 'auto_complete_for_tag_name'}, :tokens => [','] }
@@ -3,9 +3,9 @@
3
3
  %h3
4
4
  =:why_sign_up.l
5
5
  %ul.list.checks
6
- %li
6
+ %li
7
7
  = :sign_up_reason_1.l
8
- %li
8
+ %li
9
9
  = :sign_up_reason_2.l
10
10
 
11
11
  -box :class => 'alt' do
@@ -22,7 +22,7 @@
22
22
  %h3=:sign_up.l
23
23
  = error_messages_for :user
24
24
  = form_for :user, :url => users_path, :html => {:class => 'MainForm'} do |f|
25
- %label{"for"=>"user_login"}
25
+ %label{"for"=>"user_login"}
26
26
  =:username.l
27
27
  \:
28
28
  %em=:required_your_username_must_not_contain_numerals_spaces_or_special_characters.l
@@ -1,5 +1,5 @@
1
1
  -box do
2
- = form_tag( statistics_user_path(@user), :class => "MainForm") do
2
+ = form_tag( statistics_user_path(@user), :class => "MainForm", :method => :get) do
3
3
  %label= :month.l+":"
4
4
  = select_month(@month)
5
5
  = select_year(@month, :start_year => 1.years.ago.year, :end_year => 1.years.from_now.year)
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
 
14
14
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
15
15
  s.authors = ["Bruno Bornsztein"]
16
- s.date = "2011-11-18"
16
+ s.date = "2013-08-13"
17
17
  s.email = "admin@curbly.com"
18
18
  s.extra_rdoc_files = [
19
19
  "LICENSE",
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  s.add_dependency(%q<cocaine>, ["0.3.2"])
45
45
  s.add_dependency(%q<acts_as_commentable>, ["= 3.0.1"])
46
46
  s.add_dependency(%q<recaptcha>, [">= 0"])
47
- s.add_dependency(%q<omniauth>, ["= 0.3.2"])
47
+ s.add_dependency(%q<omniauth>, ["~> 1.1.0"])
48
48
  s.add_dependency(%q<prototype-rails>, [">= 0"])
49
49
  s.add_dependency(%q<rails_autolink>, [">= 0"])
50
50
  s.add_dependency(%q<meta_search>, ["= 1.1.3"])
@@ -579,7 +579,7 @@ de-DE:
579
579
  #en: joined: joined
580
580
  joined: Mitglied seit
581
581
  #en: joined_the_site: joined %{site}
582
- joined_the_site: %{site} beigetreten
582
+ joined_the_site: "%{site} beigetreten"
583
583
  #en: just_uploading_one_photo: Just uploading one photo?
584
584
  just_uploading_one_photo: Nur ein Foto hochladen?
585
585
  #en: keywords: Keywords
@@ -922,9 +922,9 @@ en:
922
922
  #en: optional_keywords_describing_this_topic_separated_by_commas: optional keywords describing this topic, separated by commas
923
923
  optional_keywords_describing_this_topic_separated_by_commas: optional keywords describing this topic, separated by commas
924
924
  #en: yes_status: yes
925
- yes: yes
925
+ yes_status: "yes"
926
926
  #en: no_status: no
927
- no: no
927
+ no_status: "no"
928
928
  #en: or: or
929
929
  or: or
930
930
  #en: page: page
@@ -1659,4 +1659,4 @@ en:
1659
1659
  #en; cancel_and_go_back_to_photo_manager: "Cancel and go back to photo manager"
1660
1660
  cancel_and_go_back_to_photo_manager: "Cancel and go back to photo manager"
1661
1661
  #en: back_to_photo_manager: "Back to photo manager"
1662
- back_to_photo_manager: "Back to photo manager"
1662
+ back_to_photo_manager: "Back to photo manager"
@@ -499,7 +499,6 @@ ru-RU:
499
499
  #en: event_comments: Event Comments
500
500
  event_comments: Комментарии события
501
501
  #en: event_does_not_allow_rsvp: This event does not allow SVPs.
502
- #ut where to be, and when to be thereuOA
503
502
  event_does_not_allow_rsvp: Это событие не разрешает приглашения.
504
503
  #en: event_was_successfully_created: Event was successfully created.
505
504
  event_was_successfully_created: Событие были успешно создано.
@@ -15,8 +15,13 @@ module LocalizedApplication
15
15
  logger.debug "[I18n] loading locale: #{configatron.community_locale} from config"
16
16
  I18n.locale = configatron.community_locale
17
17
  else
18
+ domain_locale = get_matching_ui_locale( request.subdomains.first )
19
+ if domain_locale
20
+ I18n.locale = domain_locale
21
+ else
18
22
  I18n.locale = get_valid_lang_from_accept_header
19
23
  logger.debug "[I18n] found a valid http header locale: #{I18n.locale}"
24
+ end
20
25
  end
21
26
 
22
27
  logger.debug "[I18n] Locale set to #{I18n.locale}"
@@ -58,26 +63,32 @@ module LocalizedApplication
58
63
  # Returns the UI locale that best matches with the parameter
59
64
  # or nil if not found
60
65
  def get_matching_ui_locale(locale)
66
+ if !locale
67
+ return nil
68
+ end
69
+
61
70
  lang = locale[0,2].downcase
62
71
  to_try = Array.new()
63
72
  if locale[3,5]
64
73
  country = locale[3,5].upcase
65
74
  logger.debug "[I18n] trying to match locale: #{lang}-#{country} and #{lang}-*"
66
75
  to_try << "#{lang}-#{country}".to_sym
67
- to_try << "#{lang}-*".to_sym
68
76
  else
69
77
  logger.debug "[I18n] trying to match #{lang}-*"
70
- to_try << "#{lang}-*".to_sym
71
78
  end
72
79
 
80
+ to_try << "#{lang}-*".to_sym
81
+ # Try locales without countries like "en", "es" and so on
82
+ to_try << "#{lang}".to_sym
83
+
73
84
  # Check with exact matching
74
85
  to_try.each do |possible_locale|
75
- # if Globalite.ui_locales.values.include?(possible_locale)
76
- # logger.debug "[I18n] Globalite does include #{locale} matching #{possible_locale}"
77
- return possible_locale
78
- # end
86
+ matched_locale = I18n.available_locales.grep(/#{possible_locale}/)[0]
87
+ if matched_locale
88
+ return matched_locale
89
+ end
79
90
  end
80
91
 
81
92
  return nil
82
93
  end
83
- end
94
+ end
@@ -1,5 +1,5 @@
1
1
  module UrlUpload
2
-
2
+
3
3
  def data_from_url(uri)
4
4
  io = (open(URI.parse(uri)) rescue return nil)
5
5
  (class << io; self; end;).class_eval do
@@ -7,9 +7,9 @@ module UrlUpload
7
7
  end
8
8
  io
9
9
  end
10
-
10
+
11
11
  def validate
12
12
  errors.add("filename", "is invalid") if filename? && %w(index.html index.htm).include?(filename.downcase)
13
13
  end
14
-
15
- end
14
+
15
+ end
@@ -1,7 +1,7 @@
1
1
  module CommunityEngine
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 1
4
+ MINOR = 3
5
5
  PATCH = 0
6
6
  BUILD = nil
7
7
 
@@ -15,10 +15,11 @@ class TopicsControllerTest < ActionController::TestCase
15
15
  end
16
16
 
17
17
  def test_should_show_topic_as_rss
18
+ content_type 'application/rss+xml'
18
19
  get :show, :forum_id => forums(:rails).id, :id => topics(:pdi).id, :format => 'rss'
19
20
  assert_response :success
20
21
  end
21
-
22
+
22
23
  def test_should_show_topic_as_xml
23
24
  content_type 'application/xml'
24
25
  get :show, :forum_id => forums(:rails).id, :id => topics(:pdi).id, :format => 'xml'
@@ -50,7 +51,7 @@ class TopicsControllerTest < ActionController::TestCase
50
51
  assert assigns(:topic).sticky?
51
52
  assert assigns(:topic).locked?
52
53
  end
53
-
54
+
54
55
  def test_should_allow_admin_to_sticky_and_lock
55
56
  login_as :admin
56
57
  post :create, :forum_id => forums(:rails).id, :topic => { :title => 'blah2', :sticky => "1", :locked => "1", :body => 'foo' }
@@ -63,9 +64,9 @@ class TopicsControllerTest < ActionController::TestCase
63
64
  def test_should_not_create_topic_without_body
64
65
  counts = lambda { [Topic.count, SbPost.count] }
65
66
  old = counts.call
66
-
67
+
67
68
  login_as :aaron
68
-
69
+
69
70
  post :create, :forum_id => forums(:rails).id, :topic => { :title => 'blah', :sb_posts_attributes => { "0" => { :body => '' } } }
70
71
  assert assigns(:topic)
71
72
  assert assigns(:post)
@@ -78,14 +79,14 @@ class TopicsControllerTest < ActionController::TestCase
78
79
  def test_should_create_topic
79
80
  counts = lambda { [Topic.count, SbPost.count, forums(:rails).topics_count, forums(:rails).sb_posts_count, users(:aaron).sb_posts_count] }
80
81
  old = counts.call
81
-
82
+
82
83
  login_as :aaron
83
84
  post :create, :forum_id => forums(:rails).id, :topic => { :title => 'blah', :sb_posts_attributes => { "0" => { :body => 'foo' } } }, :tag_list => 'tag1, tag2'
84
85
  assert assigns(:topic)
85
86
  assert assigns(:post)
86
87
  assert_redirected_to forum_topic_path(forums(:rails), assigns(:topic))
87
88
  [forums(:rails), users(:aaron)].each(&:reload)
88
-
89
+
89
90
  assert_equal old.collect { |n| n + 1}, counts.call
90
91
  assert_equal ['tag1', 'tag2'], Topic.find(assigns(:topic).id).tag_list
91
92
  end
@@ -94,7 +95,7 @@ class TopicsControllerTest < ActionController::TestCase
94
95
  def test_should_delete_topic
95
96
  counts = lambda { [SbPost.count, forums(:rails).topics_count, forums(:rails).sb_posts_count] }
96
97
  old = counts.call
97
-
98
+
98
99
  login_as :admin
99
100
  delete :destroy, :forum_id => forums(:rails).id, :id => topics(:ponies).id
100
101
  assert_redirected_to forum_path(forums(:rails))
@@ -162,7 +163,7 @@ class TopicsControllerTest < ActionController::TestCase
162
163
  get :edit, :forum_id => 1, :id => 1
163
164
  assert_response :success
164
165
  end
165
-
166
+
166
167
  def test_should_update_own_post
167
168
  login_as :sam
168
169
  put :update, :forum_id => forums(:rails).id, :id => topics(:ponies).id, :topic => { }, :tag_list => 'tagX, tagY'
@@ -6,24 +6,24 @@ class UsersControllerTest < ActionController::TestCase
6
6
  def test_should_get_index
7
7
  get :index
8
8
  assert_response :success
9
-
9
+
10
10
  get :index, :tag_name => tags(:misc)
11
11
  assert_response :success
12
-
12
+
13
13
  get :index, :state_id => states(:minnesota).id
14
14
  assert_response :success
15
-
15
+
16
16
  get :index, :metro_area_id => metro_areas(:twincities).id
17
17
  assert_response :success
18
18
  end
19
-
19
+
20
20
  def test_should_get_edit_account
21
21
  login_as :quentin
22
22
  assert_recognizes({:controller => 'users', :action => 'edit_account'}, {:path => '/account/edit', :method => :get})
23
23
  get :edit_account
24
24
  assert_response :success
25
- end
26
-
25
+ end
26
+
27
27
  def test_should_toggle_moderator
28
28
  login_as :admin
29
29
  assert !users(:quentin).moderator?
@@ -32,15 +32,15 @@ class UsersControllerTest < ActionController::TestCase
32
32
  put :toggle_moderator, :id => users(:quentin)
33
33
  assert !users(:quentin).reload.moderator?
34
34
  end
35
-
35
+
36
36
  def test_should_not_toggle_featured_writer_if_not_admin
37
37
  login_as :quentin
38
38
  put :toggle_moderator, :id => users(:quentin)
39
39
  assert_redirected_to :login_url
40
40
  assert !users(:quentin).reload.moderator?
41
41
  end
42
-
43
-
42
+
43
+
44
44
  def test_should_toggle_featured_writer
45
45
  login_as :admin
46
46
  assert !users(:quentin).featured_writer?
@@ -49,51 +49,51 @@ class UsersControllerTest < ActionController::TestCase
49
49
  put :toggle_featured, :id => users(:quentin)
50
50
  assert !users(:quentin).reload.featured_writer?
51
51
  end
52
-
52
+
53
53
  def test_should_not_toggle_featured_writer_if_not_admin
54
54
  login_as :quentin
55
55
  put :toggle_featured, :id => users(:quentin)
56
56
  assert_redirected_to login_url
57
57
  assert !users(:quentin).reload.featured_writer?
58
58
  end
59
-
59
+
60
60
  def test_should_get_signup_completed
61
61
  login_as :quentin
62
-
62
+
63
63
  get :signup_completed, :id => users(:quentin)
64
64
  assert_response :success
65
65
  end
66
-
66
+
67
67
  def test_should_get_welcome_photo
68
- login_as :quentin
68
+ login_as :quentin
69
69
  get :welcome_photo, :id => users(:quentin).id
70
70
  assert_response :success
71
71
  end
72
-
72
+
73
73
  def test_should_get_welcome_about
74
74
  login_as :quentin
75
75
  get :welcome_about, :id => users(:quentin).id
76
76
  assert_response :success
77
77
  end
78
-
78
+
79
79
  def test_should_get_welcome_invite
80
80
  login_as :quentin
81
81
  get :welcome_invite, :id => users(:quentin).id
82
82
  assert_response :success
83
83
  end
84
-
84
+
85
85
  def test_should_get_new
86
86
  get :new
87
87
  assert_response :success
88
88
  end
89
-
89
+
90
90
  def test_should_allow_signup
91
91
  assert_difference User, :count do
92
92
  create_user
93
93
  assert_response :redirect
94
94
  end
95
95
  end
96
-
96
+
97
97
  def test_should_require_login_on_signup
98
98
  assert_no_difference User, :count do
99
99
  create_user( :user => {:login => nil})
@@ -101,7 +101,7 @@ class UsersControllerTest < ActionController::TestCase
101
101
  assert_response :success
102
102
  end
103
103
  end
104
-
104
+
105
105
  def test_should_require_password_on_signup
106
106
  assert_no_difference User, :count do
107
107
  create_user( :user => {:password => nil})
@@ -109,7 +109,7 @@ class UsersControllerTest < ActionController::TestCase
109
109
  assert_response :success
110
110
  end
111
111
  end
112
-
112
+
113
113
  def test_should_require_password_confirmation_on_signup
114
114
  assert_no_difference User, :count do
115
115
  create_user( :user => {:password_confirmation => nil})
@@ -117,7 +117,7 @@ class UsersControllerTest < ActionController::TestCase
117
117
  assert_response :success
118
118
  end
119
119
  end
120
-
120
+
121
121
  def test_should_require_email_on_signup
122
122
  assert_no_difference User, :count do
123
123
  create_user( :user => {:email => nil})
@@ -125,95 +125,95 @@ class UsersControllerTest < ActionController::TestCase
125
125
  assert_response :success
126
126
  end
127
127
  end
128
-
128
+
129
129
  def test_should_render_new_form_when_signing_up_without_required_attributes
130
130
  create_user(:user => {:password => nil})
131
131
  assert_response :success
132
132
  end
133
-
133
+
134
134
  def test_should_deactivate_and_logout
135
135
  login_as :quentin
136
136
  assert users(:quentin).active?
137
137
  put :deactivate, :id => users(:quentin).id
138
- assert !users(:quentin).reload.active?
138
+ assert !users(:quentin).reload.active?
139
139
  assert_redirected_to login_path
140
140
  end
141
-
141
+
142
142
  def test_should_activate_user
143
143
  users(:quentin).activated_at = nil
144
144
  users(:quentin).activation_code = ':quentin_activation_code'
145
145
  users(:quentin).save!
146
146
  login_as :quentin
147
147
  assert_nil UserSession.find
148
-
148
+
149
149
  users(:quentin).activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
150
150
  users(:quentin).save!
151
-
151
+
152
152
  get :activate, :id => users(:quentin).activation_code
153
153
  assert_equal users(:quentin), UserSession.find.record
154
- end
155
-
154
+ end
155
+
156
156
  def test_should_fail_to_activate_user
157
157
  users(:quentin).activated_at = nil
158
158
  users(:quentin).activation_code = nil
159
159
  users(:quentin).save!
160
160
  login_as :quentin
161
161
  assert_nil UserSession.find
162
-
162
+
163
163
  get :activate, :id => 'bad_activation_code'
164
164
  assert_nil UserSession.find
165
- end
166
-
165
+ end
166
+
167
167
  def test_should_show_user
168
168
  get :show, :id => users(:quentin)
169
169
  assert_response :success
170
170
  end
171
-
171
+
172
172
  def test_should_not_show_private_user
173
173
  get :show, :id => users(:privateuser).id
174
174
  assert_response :redirect
175
175
  end
176
-
176
+
177
177
  def test_should_list_users
178
178
  get :index
179
179
  assert_equal assigns(:users).size, 13
180
-
180
+
181
181
  assert_response :success
182
182
  end
183
-
183
+
184
184
  def test_should_fill_states_on_detroit_search
185
185
  #state drop down not being enabled
186
186
  get :index, :metro_area_id => metro_areas(:detroit).id
187
187
  assert_equal assigns(:states).size, State.count
188
188
  assert_response :success
189
189
  end
190
-
190
+
191
191
  def test_should_empty_states_on_berlin_search
192
192
  #state drop down not being enabled
193
193
  get :index, :metro_area_id => metro_areas(:berlin).id
194
194
  assert_equal assigns(:states).size, 0
195
195
  assert_response :success
196
196
  end
197
-
197
+
198
198
  def test_should_show_edit_form
199
199
  login_as :quentin
200
200
  get :edit, :id => users(:quentin).id
201
201
  assert_response :success
202
202
  end
203
-
203
+
204
204
  def test_should_not_show_edit_form
205
205
  login_as :quentin
206
206
  get :edit, :id => users(:aaron)
207
207
  assert_redirected_to login_path
208
208
  end
209
-
209
+
210
210
  def test_should_update_user
211
211
  login_as :quentin
212
212
  put :update, :id => users(:quentin), :user => {:email => "changed_email@email.com"}
213
213
  assert_redirected_to user_path(users(:quentin).reload)
214
214
  assert_equal assigns(:user).email, "changed_email@email.com"
215
215
  end
216
-
216
+
217
217
  def test_should_update_user_tags
218
218
  login_as :quentin
219
219
  users(:quentin).tag_list = ''
@@ -222,13 +222,13 @@ class UsersControllerTest < ActionController::TestCase
222
222
  assert_redirected_to user_path(users(:quentin).reload)
223
223
  assert_equal users(:quentin).tag_list, ['tag1', 'tag2']
224
224
  end
225
-
225
+
226
226
  def test_should_not_update_user
227
227
  login_as :quentin
228
228
  put :update, :id => users(:aaron), :user => {:login => "changed_login", :email => "changed_email@email.com"}
229
229
  assert_redirected_to login_path
230
230
  end
231
-
231
+
232
232
  def test_should_destroy_user
233
233
  login_as :admin
234
234
  assert_difference User, :count, -1 do
@@ -236,110 +236,114 @@ class UsersControllerTest < ActionController::TestCase
236
236
  assert_response :redirect
237
237
  end
238
238
  end
239
-
239
+
240
240
  def test_should_not_destroy_user
241
241
  login_as :aaron
242
242
  assert_no_difference User, :count do
243
243
  delete :destroy, :id => users(:quentin)
244
244
  assert_redirected_to login_path
245
- end
245
+ end
246
246
  end
247
-
247
+
248
248
  def test_should_never_destroy_admin
249
249
  login_as :admin
250
250
  assert_no_difference User, :count do
251
251
  delete :destroy, :id => users(:admin)
252
252
  assert_response :redirect
253
- end
253
+ end
254
254
  end
255
-
255
+
256
256
  def test_should_upload_avatar
257
257
  login_as :quentin
258
258
  put :update, :id => users(:quentin).id, :user => {:avatar_attributes => {:photo => fixture_file_upload('/files/library.jpg', 'image/jpg')}}
259
- assert users(:quentin).reload.avatar.photo_file_name, "library.jpg"
259
+ assert_equal users(:quentin).reload.avatar.photo_file_name, "library.jpg"
260
+ end
261
+
262
+ def test_should_upload_avatar_from_url
263
+ login_as :quentin
264
+ put :update, :id => users(:quentin).id, :user => {:avatar_attributes => {:photo_remote_url => 'http://www.google.com/intl/en_ALL/images/logo.gif'}}
265
+ assert_equal users(:quentin).reload.avatar.photo_file_name, "library.jpg" #UrlUpload is mocked in test helper
260
266
  end
261
-
267
+
262
268
  def test_should_not_delete_existing_avatar_if_file_field_is_blank
263
269
  login_as :quentin
264
270
  put :update, :id => users(:quentin).id, :user => {:avatar_attributes => {:photo => fixture_file_upload('/files/library.jpg', 'image/jpg')}}
265
271
  assert users(:quentin).reload.avatar.photo_file_name, "library.jpg"
266
-
272
+
267
273
  put :update, :id => users(:quentin).id, :user => {}
268
- assert users(:quentin).reload.avatar.photo_file_name, "library.jpg"
274
+ assert_equal users(:quentin).reload.avatar.photo_file_name, "library.jpg"
269
275
  end
270
-
276
+
271
277
  def test_should_crop_profile_photo
272
278
  login_as :quentin
273
279
  avatar = Photo.new(:photo => fixture_file_upload('/files/library.jpg', 'image/jpg'))
274
280
  avatar.user = users(:quentin)
275
281
  avatar.save!
276
-
282
+
277
283
  users(:quentin).avatar = avatar
278
284
  users(:quentin).save
279
-
285
+
280
286
  put :crop_profile_photo, :id => users(:quentin).id, :x1 => 0, :y1 => 0, :width => 290, :height => 320
281
-
287
+
282
288
  assert_redirected_to user_path(users(:quentin))
283
289
  end
284
-
290
+
285
291
  def test_should_upload_profile_photo
286
292
  login_as :quentin
287
-
288
293
  put :upload_profile_photo, :id => users(:quentin), :avatar => {:photo => fixture_file_upload('/files/library.jpg', 'image/jpg')}
289
-
290
- assert_redirected_to crop_profile_photo_user_path(users(:quentin).reload)
294
+ assert_redirected_to crop_profile_photo_user_path(users(:quentin).reload)
291
295
  end
292
-
296
+
293
297
  def test_create_friendship_with_invited_user
294
298
  assert_difference User, :count do
295
299
  assert_difference Friendship, :count, 2 do
296
300
  create_user({:inviter_code => users(:quentin).invite_code , :inviter_id => users(:quentin).id })
297
301
  end
298
302
  end
299
- assert_response :redirect
303
+ assert_response :redirect
300
304
  end
301
-
305
+
302
306
  def test_should_update_account
303
307
  login_as :quentin
304
308
  put :update_account, :user => {:login => 'changed_login'}, :id => users(:quentin)
305
309
  assert_redirected_to user_path(users(:quentin).reload)
306
310
  assert_equal assigns(:user).login, 'changed_login'
307
311
  end
308
-
312
+
309
313
  def test_should_remind_username
310
314
  assert_difference ActionMailer::Base.deliveries, :length, 1 do
311
315
  post :forgot_username, :email => users(:quentin).email
312
- assert_redirected_to login_path
316
+ assert_redirected_to login_path
313
317
  end
314
318
  end
315
-
319
+
316
320
  def test_should_resend_activation
317
321
  users(:quentin).activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
318
322
  users(:quentin).activated_at = nil
319
323
  users(:quentin).save!
320
-
324
+
321
325
  assert_difference ActionMailer::Base.deliveries, :length, 1 do
322
326
  post :resend_activation, :id => users(:quentin)
323
- assert_redirected_to login_path
324
- end
327
+ assert_redirected_to login_path
328
+ end
325
329
  end
326
-
330
+
327
331
  def test_should_not_resend_activation_for_active_user
328
332
  assert_no_difference ActionMailer::Base.deliveries, :length do
329
333
  post :resend_activation, :id => users(:quentin).to_param
330
334
  assert_response :success
331
335
  assert_equal :activation_email_not_sent_message.l, flash[:notice]
332
- end
336
+ end
333
337
  end
334
-
338
+
335
339
  def test_should_not_resend_activation_for_nonexistent_user
336
340
  assert_no_difference ActionMailer::Base.deliveries, :length do
337
- assert_raise(ActiveRecord::RecordNotFound) {
341
+ assert_raise(ActiveRecord::RecordNotFound) {
338
342
  post :resend_activation, :id => "nonexistant"
339
343
  }
340
- end
344
+ end
341
345
  end
342
-
346
+
343
347
  def test_assume_should_assume_users_id
344
348
  login_as :admin
345
349
  post :assume, :id => users(:quentin)
@@ -348,7 +352,7 @@ class UsersControllerTest < ActionController::TestCase
348
352
  assert_not_nil session[:admin_id]
349
353
  assert_equal users(:admin).id, session[:admin_id]
350
354
  end
351
-
355
+
352
356
  def test_only_admin_can_assume_id
353
357
  login_as :quentin
354
358
  post :assume, :id => users(:aaron).id
@@ -356,7 +360,7 @@ class UsersControllerTest < ActionController::TestCase
356
360
  assert_not_equal UserSession.find.record, users(:aaron)
357
361
  assert_nil session[:admin_id]
358
362
  end
359
-
363
+
360
364
  def test_only_admin_can_assume_id_js
361
365
  login_as :quentin
362
366
  post :assume, :id => users(:aaron).id, :format => 'js'
@@ -364,7 +368,7 @@ class UsersControllerTest < ActionController::TestCase
364
368
  assert_not_equal UserSession.find.record, users(:aaron)
365
369
  assert_nil session[:admin_id]
366
370
  end
367
-
371
+
368
372
  def test_return_admin_should_set_user_to_admin
369
373
  login_as :quentin
370
374
  @request.session[:admin_id] = users(:admin).id
@@ -373,7 +377,7 @@ class UsersControllerTest < ActionController::TestCase
373
377
  assert_nil session[:admin_id]
374
378
  assert_equal users(:admin), UserSession.find.record
375
379
  end
376
-
380
+
377
381
  def test_only_admin_can_return_to_admin
378
382
  login_as :quentin
379
383
  @request.session[:admin_id] = users(:admin).id
@@ -382,7 +386,7 @@ class UsersControllerTest < ActionController::TestCase
382
386
  assert_nil session[:admin_id]
383
387
  assert_equal users(:admin), UserSession.find.record
384
388
  end
385
-
389
+
386
390
  def test_should_decrement_metro_area_count
387
391
  initial_count = metro_areas(:twincities).users_count
388
392
  quentin = users(:quentin)
@@ -390,8 +394,8 @@ class UsersControllerTest < ActionController::TestCase
390
394
  quentin.save
391
395
  assert_equal(metro_areas(:twincities).reload.users_count, metro_areas(:twincities).reload.users.size )
392
396
  assert_equal(metro_areas(:detroit).reload.users_count, metro_areas(:detroit).reload.users.size )
393
- end
394
-
397
+ end
398
+
395
399
  def test_should_increment_metro_area_count
396
400
  initial_count = metro_areas(:detroit).users_count
397
401
  aaron = users(:aaron)
@@ -399,20 +403,20 @@ class UsersControllerTest < ActionController::TestCase
399
403
  aaron.save!
400
404
  assert_equal metro_areas(:detroit).reload.users_count, initial_count + 1
401
405
  assert_equal(metro_areas(:detroit).reload.users_count, metro_areas(:detroit).reload.users.size )
402
- end
403
-
406
+ end
407
+
404
408
  def test_should_get_stats_if_admin
405
409
  login_as :admin
406
410
  get :statistics, :id => users(:super_writer).id
407
411
  assert_response :success
408
412
  end
409
-
413
+
410
414
  def test_should_not_get_stats_if_not_admin
411
415
  login_as :quentin
412
416
  get :statistics, :id => users(:super_writer).id
413
417
  assert_response :redirect
414
418
  end
415
-
419
+
416
420
  def test_should_get_with_date_param
417
421
  login_as :admin
418
422
  post = users(:quentin).posts.last
@@ -420,33 +424,33 @@ class UsersControllerTest < ActionController::TestCase
420
424
  assert_response :success
421
425
  assert !assigns(:posts).empty?
422
426
  end
423
-
424
-
427
+
428
+
425
429
  def test_should_get_dashboard_with_no_friends
426
430
  login_as :aaron
427
431
  assert users(:aaron).network_activity.empty?
428
432
  get :dashboard, :id => users(:aaron).friendly_id
429
433
  assert_response :success
430
434
  end
431
-
435
+
432
436
  def test_should_get_dashboard_with_no_recommended_posts
433
437
  login_as :quentin
434
438
  users(:aaron).tag_list = 'hansel,gretel'
435
439
  users(:aaron).save
436
-
440
+
437
441
  assert !users(:aaron).tags.reload.empty?
438
-
439
- assert users(:aaron).recommended_posts.empty?
442
+
443
+ assert users(:aaron).recommended_posts.empty?
440
444
  get :dashboard, :id => users(:aaron).friendly_id
441
445
  assert_response :success
442
446
  end
443
-
447
+
444
448
  def test_should_show_user_statistics
445
449
  login_as :admin
446
450
  get :statistics, :id => users(:quentin).id
447
451
  assert_response :success
448
452
  end
449
-
453
+
450
454
  test 'should delete selected users in admin users action' do
451
455
  login_as :admin
452
456
  assert_difference User, :count, -1 do
@@ -454,22 +458,22 @@ class UsersControllerTest < ActionController::TestCase
454
458
  end
455
459
  assert_redirected_to admin_users_path
456
460
  end
457
-
461
+
458
462
  test 'should store location for anonymous page' do
459
463
  return_to = session[:return_to]
460
464
  get :index
461
465
  assert_not_equal return_to, session[:return_to]
462
466
  assert_equal "http://test.host/users", session[:return_to]
463
467
  end
464
-
465
-
468
+
469
+
466
470
  protected
467
471
  def create_user(options = {})
468
472
  params = {:user => {:login => 'quire', :email => 'quire@example.com', :password => 'quire123', :password_confirmation => 'quire123', :birthday => configatron.min_age.years.ago}}
469
473
  user_opts = options.delete(:user)
470
474
  params[:user].merge!(user_opts) if user_opts
471
-
475
+
472
476
  post :create, params.merge(options)
473
477
  end
474
-
478
+
475
479
  end