Commit 15829a14bbcbda0869d7dbdbc959be009a0905ac

Authored by Daniela Feitosa
Committed by Joenio Costa
1 parent 5ca65170

Fixed redirections of noosfero

After creation/edition of an article, the user is redirected to the article
Used back_to to store the page to return

(ActionItem1424)
app/controllers/my_profile/cms_controller.rb
@@ -81,14 +81,11 @@ class CmsController < MyProfileController @@ -81,14 +81,11 @@ class CmsController < MyProfileController
81 @type = params[:type] || @article.class.to_s 81 @type = params[:type] || @article.class.to_s
82 82
83 refuse_blocks 83 refuse_blocks
84 - if !@article.nil? && @article.blog? || !@type.nil? && @type == 'Blog'  
85 - @back_url = url_for(:controller => 'profile_editor', :profile => profile.identifier)  
86 - end  
87 - record_coming_from_public_view 84 + record_coming
88 if request.post? 85 if request.post?
89 @article.last_changed_by = user 86 @article.last_changed_by = user
90 if @article.update_attributes(params[:article]) 87 if @article.update_attributes(params[:article])
91 - redirect_back 88 + redirect_to @article.view_url
92 return 89 return
93 end 90 end
94 end 91 end
@@ -99,6 +96,7 @@ class CmsController < MyProfileController @@ -99,6 +96,7 @@ class CmsController < MyProfileController
99 96
100 # user must choose an article type first 97 # user must choose an article type first
101 98
  99 + record_coming
102 @type = params[:type] 100 @type = params[:type]
103 if @type.blank? 101 if @type.blank?
104 @article_types = [] 102 @article_types = []
@@ -110,12 +108,9 @@ class CmsController < MyProfileController @@ -110,12 +108,9 @@ class CmsController < MyProfileController
110 }) 108 })
111 end 109 end
112 @parent_id = params[:parent_id] 110 @parent_id = params[:parent_id]
113 - render :action => 'select_article_type', :layout => false 111 + render :action => 'select_article_type', :layout => false, :back_to => @back_to
114 return 112 return
115 else 113 else
116 - if @type == 'Blog'  
117 - @back_url = url_for(:controller => 'profile_editor', :profile => profile.identifier)  
118 - end  
119 refuse_blocks 114 refuse_blocks
120 end 115 end
121 116
@@ -131,13 +126,11 @@ class CmsController < MyProfileController @@ -131,13 +126,11 @@ class CmsController < MyProfileController
131 @parent_id = parent.id 126 @parent_id = parent.id
132 end 127 end
133 128
134 - record_creating_from_public_view  
135 -  
136 @article.profile = profile 129 @article.profile = profile
137 @article.last_changed_by = user 130 @article.last_changed_by = user
138 if request.post? 131 if request.post?
139 if @article.save 132 if @article.save
140 - redirect_back 133 + redirect_to @article.view_url
141 return 134 return
142 end 135 end
143 end 136 end
@@ -159,29 +152,36 @@ class CmsController < MyProfileController @@ -159,29 +152,36 @@ class CmsController < MyProfileController
159 @article = @parent = check_parent(params[:parent_id]) 152 @article = @parent = check_parent(params[:parent_id])
160 @target = @parent ? ('/%s/%s' % [profile.identifier, @parent.full_name]) : '/%s' % profile.identifier 153 @target = @parent ? ('/%s/%s' % [profile.identifier, @parent.full_name]) : '/%s' % profile.identifier
161 @folders = Folder.find(:all, :conditions => { :profile_id => profile }) 154 @folders = Folder.find(:all, :conditions => { :profile_id => profile })
162 - record_coming_from_public_view if @article 155 + @media_listing = params[:media_listing]
  156 + if @article && !@media_listing
  157 + record_coming
  158 + end
163 if request.post? && params[:uploaded_files] 159 if request.post? && params[:uploaded_files]
164 params[:uploaded_files].each do |file| 160 params[:uploaded_files].each do |file|
165 @uploaded_files << UploadedFile.create(:uploaded_data => file, :profile => profile, :parent => @parent) unless file == '' 161 @uploaded_files << UploadedFile.create(:uploaded_data => file, :profile => profile, :parent => @parent) unless file == ''
166 end 162 end
167 @errors = @uploaded_files.select { |f| f.errors.any? } 163 @errors = @uploaded_files.select { |f| f.errors.any? }
168 - @back_to = params[:back_to]  
169 if @errors.any? 164 if @errors.any?
170 - if @back_to && @back_to == 'media_listing' 165 + if @media_listing
171 flash[:notice] = _('Could not upload all files') 166 flash[:notice] = _('Could not upload all files')
172 - redirect_back 167 + redirect_to :action => 'media_listing'
173 else 168 else
174 render :action => 'upload_files', :parent_id => @parent_id 169 render :action => 'upload_files', :parent_id => @parent_id
175 end 170 end
176 else 171 else
177 - if params[:back_to]  
178 - redirect_back 172 + if @media_listing
  173 + flash[:notice] = _('All files were uploaded successfully')
  174 + redirect_to :action => 'media_listing'
179 else 175 else
180 - redirect_to( if @parent  
181 - {:action => 'view', :id => @parent.id} 176 + if @back_to
  177 + redirect_to @back_to
182 else 178 else
183 - {:action => 'index'}  
184 - end) 179 + redirect_to( if @parent
  180 + {:action => 'view', :id => @parent.id}
  181 + else
  182 + {:action => 'index'}
  183 + end)
  184 + end
185 end 185 end
186 end 186 end
187 end 187 end
@@ -212,7 +212,7 @@ class CmsController &lt; MyProfileController @@ -212,7 +212,7 @@ class CmsController &lt; MyProfileController
212 212
213 def publish 213 def publish
214 @article = profile.articles.find(params[:id]) 214 @article = profile.articles.find(params[:id])
215 - record_coming_from_public_view 215 + record_coming
216 @groups = profile.memberships - [profile] 216 @groups = profile.memberships - [profile]
217 @marked_groups = [] 217 @marked_groups = []
218 groups_ids = profile.memberships.map{|m|m.id.to_s} 218 groups_ids = profile.memberships.map{|m|m.id.to_s}
@@ -233,7 +233,11 @@ class CmsController &lt; MyProfileController @@ -233,7 +233,11 @@ class CmsController &lt; MyProfileController
233 end 233 end
234 if @failed.blank? 234 if @failed.blank?
235 flash[:notice] = _("Your publish request was sent successfully") 235 flash[:notice] = _("Your publish request was sent successfully")
236 - redirect_back 236 + if @back_to
  237 + redirect_to @back_to
  238 + else
  239 + redirect_to @article.view_url
  240 + end
237 end 241 end
238 end 242 end
239 end 243 end
@@ -258,7 +262,7 @@ class CmsController &lt; MyProfileController @@ -258,7 +262,7 @@ class CmsController &lt; MyProfileController
258 @image_folders = @folders.select {|f| f.children.any? {|c| c.image?} } 262 @image_folders = @folders.select {|f| f.children.any? {|c| c.image?} }
259 @document_folders = @folders.select {|f| f.children.any? {|c| !c.image? && c.kind_of?(UploadedFile) } } 263 @document_folders = @folders.select {|f| f.children.any? {|c| !c.image? && c.kind_of?(UploadedFile) } }
260 264
261 - @back_to = 'media_listing' 265 + @media_listing = true
262 266
263 respond_to do |format| 267 respond_to do |format|
264 format.html { render :layout => false} 268 format.html { render :layout => false}
@@ -273,42 +277,11 @@ class CmsController &lt; MyProfileController @@ -273,42 +277,11 @@ class CmsController &lt; MyProfileController
273 277
274 protected 278 protected
275 279
276 - def redirect_back  
277 - if params[:back_to] == 'control_panel'  
278 - redirect_to :controller => 'profile_editor', :profile => @profile.identifier  
279 - elsif params[:back_to] == 'public_view'  
280 - redirect_to @article.view_url.merge(Noosfero.url_options)  
281 - elsif params[:back_to] == 'media_listing'  
282 - redirect_to :action => 'media_listing'  
283 - elsif @article.parent  
284 - redirect_to :action => 'view', :id => @article.parent  
285 - elsif @article.folder? && !@article.blog? && @article.parent  
286 - redirect_to :action => 'index' 280 + def record_coming
  281 + if request.post?
  282 + @back_to = params[:back_to]
287 else 283 else
288 - redirect_back_or_default :action => 'index'  
289 - end  
290 - end  
291 -  
292 - def record_coming_from_public_view  
293 - referer = request.referer  
294 - referer.gsub!(/\?.*/, '') unless referer.nil?  
295 - if (maybe_ssl(url_for(@article.url)).include?(referer)) || (@article == profile.home_page && maybe_ssl(url_for(profile.url)).include?(referer))  
296 - @back_to = 'public_view'  
297 - @back_url = @article.view_url  
298 - end  
299 - if !request.post? and @article.blog?  
300 - store_location(request.referer)  
301 - end  
302 - end  
303 -  
304 - def record_creating_from_public_view  
305 - referer = request.referer  
306 - if (referer =~ Regexp.new("^#{(url_for(profile.url).sub('https:', 'https?:'))}")) || params[:back_to] == 'public_view'  
307 - @back_to = 'public_view'  
308 - @back_url = referer  
309 - end  
310 - if !request.post? and @article.blog?  
311 - store_location(request.referer) 284 + @back_to = params[:back_to] || request.referer
312 end 285 end
313 end 286 end
314 287
app/controllers/public/content_viewer_controller.rb
@@ -67,9 +67,6 @@ class ContentViewerController &lt; ApplicationController @@ -67,9 +67,6 @@ class ContentViewerController &lt; ApplicationController
67 return 67 return
68 end 68 end
69 69
70 - # store location if the page is not a download  
71 - store_location  
72 -  
73 @form_div = params[:form] 70 @form_div = params[:form]
74 71
75 if request.post? && params[:comment] && params[self.icaptcha_field].blank? && params[:confirm] == 'true' && @page.accept_comments? 72 if request.post? && params[:comment] && params[self.icaptcha_field].blank? && params[:confirm] == 'true' && @page.accept_comments?
app/controllers/public/invite_controller.rb
@@ -23,7 +23,11 @@ class InviteController &lt; PublicController @@ -23,7 +23,11 @@ class InviteController &lt; PublicController
23 elsif !contacts_to_invite.empty? 23 elsif !contacts_to_invite.empty?
24 Invitation.invite(current_user.person, contacts_to_invite, params[:mail_template], profile) 24 Invitation.invite(current_user.person, contacts_to_invite, params[:mail_template], profile)
25 flash[:notice] = _('Your invitations have been sent.') 25 flash[:notice] = _('Your invitations have been sent.')
26 - redirect_back_or_default :controller => 'profile' 26 + if profile.person?
  27 + redirect_to :controller => 'friends'
  28 + else
  29 + redirect_to :controller => 'profile_members'
  30 + end
27 else 31 else
28 flash.now[:notice] = _('Please enter a valid email address.') 32 flash.now[:notice] = _('Please enter a valid email address.')
29 end 33 end
@@ -31,8 +35,6 @@ class InviteController &lt; PublicController @@ -31,8 +35,6 @@ class InviteController &lt; PublicController
31 @manual_import_addresses = manual_import_addresses || "" 35 @manual_import_addresses = manual_import_addresses || ""
32 @webmail_import_addresses = webmail_import_addresses || [] 36 @webmail_import_addresses = webmail_import_addresses || []
33 end 37 end
34 - else  
35 - store_location(request.referer)  
36 end 38 end
37 @import_from = params[:import_from] || "manual" 39 @import_from = params[:import_from] || "manual"
38 @mail_template = params[:mail_template] || environment.invitation_mail_template(profile) 40 @mail_template = params[:mail_template] || environment.invitation_mail_template(profile)
app/controllers/public/profile_controller.rb
@@ -83,10 +83,9 @@ class ProfileController &lt; PublicController @@ -83,10 +83,9 @@ class ProfileController &lt; PublicController
83 redirect_to_before_join 83 redirect_to_before_join
84 end 84 end
85 else 85 else
86 - store_location(request.referer)  
87 if current_user.person.memberships.include?(profile) 86 if current_user.person.memberships.include?(profile)
88 flash[:notice] = _('You are already a member of "%s"') % profile.name 87 flash[:notice] = _('You are already a member of "%s"') % profile.name
89 - redirect_back_or_default profile.url 88 + redirect_to profile.url
90 return 89 return
91 end 90 end
92 if request.xhr? 91 if request.xhr?
@@ -97,15 +96,16 @@ class ProfileController &lt; PublicController @@ -97,15 +96,16 @@ class ProfileController &lt; PublicController
97 96
98 def leave 97 def leave
99 @wizard = params[:wizard] 98 @wizard = params[:wizard]
  99 + @back_to = params[:back_to] || request.referer
100 if request.post? && params[:confirmation] 100 if request.post? && params[:confirmation]
101 profile.remove_member(current_user.person) 101 profile.remove_member(current_user.person)
102 if @wizard 102 if @wizard
103 redirect_to :controller => 'search', :action => 'assets', :asset => 'communities', :wizard => true 103 redirect_to :controller => 'search', :action => 'assets', :asset => 'communities', :wizard => true
104 else 104 else
105 - redirect_back_or_default profile.url 105 + back = @back_to || profile.url
  106 + redirect_to back
106 end 107 end
107 else 108 else
108 - store_location(request.referer)  
109 if request.xhr? 109 if request.xhr?
110 render :layout => false 110 render :layout => false
111 end 111 end
@@ -146,7 +146,9 @@ class ProfileController &lt; PublicController @@ -146,7 +146,9 @@ class ProfileController &lt; PublicController
146 end 146 end
147 147
148 def store_before_join 148 def store_before_join
149 - session[:before_join] = request.referer unless logged_in? 149 + if session[:before_join].nil?
  150 + session[:before_join] = request.referer
  151 + end
150 end 152 end
151 153
152 def redirect_to_before_join 154 def redirect_to_before_join
@@ -155,7 +157,7 @@ class ProfileController &lt; PublicController @@ -155,7 +157,7 @@ class ProfileController &lt; PublicController
155 session[:before_join] = nil 157 session[:before_join] = nil
156 redirect_to back 158 redirect_to back
157 else 159 else
158 - redirect_back_or_default profile.url 160 + redirect_to profile.url
159 end 161 end
160 end 162 end
161 163
app/models/profile.rb
@@ -383,7 +383,7 @@ class Profile &lt; ActiveRecord::Base @@ -383,7 +383,7 @@ class Profile &lt; ActiveRecord::Base
383 383
384 def url_options 384 def url_options
385 options = { :host => default_hostname, :profile => (own_hostname ? nil : self.identifier) } 385 options = { :host => default_hostname, :profile => (own_hostname ? nil : self.identifier) }
386 - options.merge(Noosfero.url_options.merge(options)) 386 + options.merge(Noosfero.url_options)
387 end 387 end
388 388
389 private :generate_url, :url_options 389 private :generate_url, :url_options
app/views/cms/_upload_file_form.rhtml
@@ -15,10 +15,10 @@ @@ -15,10 +15,10 @@
15 15
16 <% button_bar do %> 16 <% button_bar do %>
17 <%= add_upload_file_field(_('More files'), {:size => size}) %> 17 <%= add_upload_file_field(_('More files'), {:size => size}) %>
18 - <% if @back_to == 'media_listing' %> 18 + <% if @media_listing %>
19 <%= submit_button :save, _('Upload') %> 19 <%= submit_button :save, _('Upload') %>
20 - <% elsif @back_url %>  
21 - <%= submit_button :save, _('Upload'), :cancel => @back_url %> 20 + <% elsif @back_to %>
  21 + <%= submit_button :save, _('Upload'), :cancel => @back_to %>
22 <% else %> 22 <% else %>
23 <%= submit_button :save, _('Upload'), :cancel => {:action => (@parent ? 'view' : 'index'), :id => @parent } %> 23 <%= submit_button :save, _('Upload'), :cancel => {:action => (@parent ? 'view' : 'index'), :id => @parent } %>
24 <% end %> 24 <% end %>
app/views/cms/edit.rhtml
@@ -37,10 +37,8 @@ @@ -37,10 +37,8 @@
37 37
38 <% button_bar do %> 38 <% button_bar do %>
39 <%= submit_button :save, _('Save') %> 39 <%= submit_button :save, _('Save') %>
40 - <% if @return_to %>  
41 - <%= button :cancel, _('Cancel'), @return_to %>  
42 - <% elsif @back_url %>  
43 - <%= button :cancel, _('Cancel'), @back_url %> 40 + <% if @back_to %>
  41 + <%= button :cancel, _('Cancel'), @back_to %>
44 <% elsif @parent_id || @article.parent %> 42 <% elsif @parent_id || @article.parent %>
45 <%= button :cancel, _('Cancel'), :action => 'view', :id => @parent_id || @article.parent %> 43 <%= button :cancel, _('Cancel'), :action => 'view', :id => @parent_id || @article.parent %>
46 <% else %> 44 <% else %>
app/views/cms/media_listing.rhtml
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
39 </div> 39 </div>
40 40
41 <% form_for('uploaded_file', :url => {:action => 'upload_files'}, :html => {:multipart => true}) do |f| %> 41 <% form_for('uploaded_file', :url => {:action => 'upload_files'}, :html => {:multipart => true}) do |f| %>
42 - <%= hidden_field_tag('back_to', @back_to) %> 42 + <%= hidden_field_tag('media_listing', @media_listing) %>
43 <%= render :partial => 'upload_file_form', :locals => { :size => '30' } %> 43 <%= render :partial => 'upload_file_form', :locals => { :size => '30' } %>
44 <% end %> 44 <% end %>
45 </div><!-- id='media-listing-upload' --> 45 </div><!-- id='media-listing-upload' -->
app/views/cms/publish.rhtml
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 <% end %> 26 <% end %>
27 27
28 <% button_bar do %> 28 <% button_bar do %>
29 - <%= submit_button 'spread', _('Publish') %> 29 + <%= submit_button 'spread', _('Publish'), :cancel => @back_to %>
30 <% end %> 30 <% end %>
31 <% end %> 31 <% end %>
32 <% else %> 32 <% else %>
app/views/cms/select_article_type.rhtml
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <ul id="article_types"> 3 <ul id="article_types">
4 <% for type in @article_types %> 4 <% for type in @article_types %>
5 <li> 5 <li>
6 - <%= link_to type[:short_description], :action => 'new', :type => type[:name], :parent_id => @parent_id %> 6 + <%= link_to type[:short_description], :action => 'new', :type => type[:name], :parent_id => @parent_id, :back_to => @back_to %>
7 <br/> <%= type[:description] %> 7 <br/> <%= type[:description] %>
8 </li> 8 </li>
9 <% end %> 9 <% end %>
app/views/profile/join.rhtml
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 </p> 5 </p>
6 6
7 <% form_tag do %> 7 <% form_tag do %>
  8 + <%= hidden_field_tag('back_to', @back_to) %>
8 <%= hidden_field_tag(:confirmation, 1) %> 9 <%= hidden_field_tag(:confirmation, 1) %>
9 <%= submit_button(:ok, _("Yes, I want to join.") % profile.name) %> 10 <%= submit_button(:ok, _("Yes, I want to join.") % profile.name) %>
10 <% if logged_in? && request.xhr? %> 11 <% if logged_in? && request.xhr? %>
app/views/profile/leave.rhtml
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 6
7 <% form_tag do %> 7 <% form_tag do %>
8 <%= hidden_field_tag(:confirmation, 1) %> 8 <%= hidden_field_tag(:confirmation, 1) %>
  9 + <%= hidden_field_tag(:back_to, @back_to) %>
9 <%= submit_button(:ok, _("Yes, I want to leave.") % profile.name) %> 10 <%= submit_button(:ok, _("Yes, I want to leave.") % profile.name) %>
10 <% if logged_in? && request.xhr? %> 11 <% if logged_in? && request.xhr? %>
11 <%= lightbox_close_button(_("No, I don't want")) %> 12 <%= lightbox_close_button(_("No, I don't want")) %>
features/blog.feature
@@ -15,25 +15,24 @@ Feature: blog @@ -15,25 +15,24 @@ Feature: blog
15 Then I should see "My Blog" 15 Then I should see "My Blog"
16 When I fill in "Title" with "My Blog" 16 When I fill in "Title" with "My Blog"
17 And I press "Save" 17 And I press "Save"
18 - And I follow "Control panel" 18 + And I go to Joao Silva's control panel
19 Then I should see "Configure blog" 19 Then I should see "Configure blog"
20 20
21 - Scenario: redirect to control panel after create blog 21 + Scenario: redirect to blog after create blog from control panel
22 Given I follow "Control panel" 22 Given I follow "Control panel"
23 And I follow "Create blog" 23 And I follow "Create blog"
24 Then I should see "My Blog" 24 Then I should see "My Blog"
25 When I fill in "Title" with "My Blog" 25 When I fill in "Title" with "My Blog"
26 And I press "Save" 26 And I press "Save"
27 - Then I should be on /myprofile/joaosilva 27 + Then I should be on /joaosilva/my-blog
28 28
29 - Scenario: redirect to cms after create blog 29 + Scenario: redirect to blog after create blog from cms
30 Given I follow "Control panel" 30 Given I follow "Control panel"
31 And I follow "Manage Content" 31 And I follow "Manage Content"
32 When I follow "New Blog" 32 When I follow "New Blog"
33 - Then I should see "My Blog"  
34 - When I fill in "Title" with "My Blog" 33 + And I fill in "Title" with "Blog from cms"
35 And I press "Save" 34 And I press "Save"
36 - Then I should be on /myprofile/joaosilva/cms 35 + Then I should be on /joaosilva/blog-from-cms
37 36
38 Scenario: create multiple blogs 37 Scenario: create multiple blogs
39 Given I follow "Control panel" 38 Given I follow "Control panel"
@@ -41,11 +40,13 @@ Feature: blog @@ -41,11 +40,13 @@ Feature: blog
41 And I follow "New Blog" 40 And I follow "New Blog"
42 And I fill in "Title" with "Blog One" 41 And I fill in "Title" with "Blog One"
43 And I press "Save" 42 And I press "Save"
  43 + Then I follow "Control panel"
  44 + And I follow "Manage Content"
44 And I follow "New Blog" 45 And I follow "New Blog"
45 And I fill in "Title" with "Blog Two" 46 And I fill in "Title" with "Blog Two"
46 And I press "Save" 47 And I press "Save"
47 Then I should not see "error" 48 Then I should not see "error"
48 - And I should be on /myprofile/joaosilva/cms 49 + And I should be on /joaosilva/blog-two
49 50
50 Scenario: cancel button back to cms 51 Scenario: cancel button back to cms
51 Given I follow "Control panel" 52 Given I follow "Control panel"
features/create_article.feature
@@ -1,61 +0,0 @@ @@ -1,61 +0,0 @@
1 -Feature: create article  
2 - As a noosfero user  
3 - I want to create new articles  
4 -  
5 - Background:  
6 - Given I am on the homepage  
7 - And the following users  
8 - | login | name |  
9 - | joaosilva | Joao Silva |  
10 - And I am logged in as "joaosilva"  
11 -  
12 - Scenario: create a folder  
13 - Given I am on Joao Silva's control panel  
14 - And I follow "Manage Content"  
15 - When I follow "New Folder"  
16 - And I fill in "Title" with "My Folder"  
17 - And I press "Save"  
18 - And I go to Joao Silva's control panel  
19 - Then I should see "My Folder"  
20 -  
21 - Scenario: redirect to the created folder  
22 - Given I am on Joao Silva's control panel  
23 - And I follow "Manage Content"  
24 - When I follow "New Folder"  
25 - And I fill in "Title" with "My Folder"  
26 - And I press "Save"  
27 - Then I should see "Content management"  
28 - And I should be on Joao Silva's cms  
29 -  
30 - Scenario: cancel button back to cms  
31 - Given I follow "Control panel"  
32 - And I follow "Manage Content"  
33 - And I follow "New Folder"  
34 - When I follow "Cancel"  
35 - Then I should be on Joao Silva's cms  
36 -  
37 - Scenario: display tag list field when creating event  
38 - Given I follow "Control panel"  
39 - And I follow "Manage Content"  
40 - And I follow "New article"  
41 - When I follow "Event"  
42 - Then I should see "Tag list"  
43 -  
44 - Scenario: display tag list field when creating folder  
45 - Given I follow "Control panel"  
46 - And I follow "Manage Content"  
47 - When I follow "New folder"  
48 - Then I should see "Tag list"  
49 -  
50 - Scenario: create new article with tags  
51 - Given I follow "Control panel"  
52 - And I follow "Manage Content"  
53 - And I follow "New article"  
54 - When I follow "Text article with Textile markup language"  
55 - Then I should see "Tag list"  
56 - When I fill in "Title" with "Article with tags"  
57 - And I fill in "Tag list" with "aurium, bug"  
58 - And I press "Save"  
59 - And I go to /joaosilva/article-with-tags  
60 - Then I should see "aurium" within "#article-tags a:first"  
61 - And I should see "bug" within "#article-tags a:last"  
features/edit_article.feature 0 → 100644
@@ -0,0 +1,116 @@ @@ -0,0 +1,116 @@
  1 +Feature: edit article
  2 + As a noosfero user
  3 + I want to create and edit articles
  4 +
  5 + Background:
  6 + Given I am on the homepage
  7 + And the following users
  8 + | login | name |
  9 + | joaosilva | Joao Silva |
  10 + And the following articles
  11 + | owner | name | body |
  12 + | joaosilva | Save the whales | ... |
  13 + And I am logged in as "joaosilva"
  14 +
  15 + Scenario: create a folder
  16 + Given I am on Joao Silva's control panel
  17 + And I follow "Manage Content"
  18 + When I follow "New Folder"
  19 + And I fill in "Title" with "My Folder"
  20 + And I press "Save"
  21 + And I go to Joao Silva's control panel
  22 + Then I should see "My Folder"
  23 +
  24 + Scenario: redirect to the created folder
  25 + Given I am on Joao Silva's control panel
  26 + And I follow "Manage Content"
  27 + When I follow "New Folder"
  28 + And I fill in "Title" with "My Folder"
  29 + And I press "Save"
  30 + Then I should see "My Folder"
  31 + And I should be on /joaosilva/my-folder
  32 +
  33 + Scenario: cancel button back to cms
  34 + Given I follow "Control panel"
  35 + And I follow "Manage Content"
  36 + And I follow "New Folder"
  37 + When I follow "Cancel"
  38 + Then I should be on Joao Silva's cms
  39 +
  40 + Scenario: display tag list field when creating event
  41 + Given I follow "Control panel"
  42 + And I follow "Manage Content"
  43 + And I follow "New article"
  44 + When I follow "Event"
  45 + Then I should see "Tag list"
  46 +
  47 + Scenario: display tag list field when creating folder
  48 + Given I follow "Control panel"
  49 + And I follow "Manage Content"
  50 + When I follow "New folder"
  51 + Then I should see "Tag list"
  52 +
  53 + Scenario: create new article with tags
  54 + Given I follow "Control panel"
  55 + And I follow "Manage Content"
  56 + And I follow "New article"
  57 + When I follow "Text article with Textile markup language"
  58 + Then I should see "Tag list"
  59 + When I fill in "Title" with "Article with tags"
  60 + And I fill in "Tag list" with "aurium, bug"
  61 + And I press "Save"
  62 + And I go to /joaosilva/article-with-tags
  63 + Then I should see "aurium" within "#article-tags a:first"
  64 + And I should see "bug" within "#article-tags a:last"
  65 +
  66 + Scenario: redirect to the created article
  67 + Given I am on Joao Silva's control panel
  68 + And I follow "Manage Content"
  69 + When I follow "New article"
  70 + When I follow "Text article with visual editor"
  71 + And I fill in "Title" with "My Article"
  72 + And I press "Save"
  73 + Then I should see "My Article"
  74 + And I should be on /joaosilva/my-article
  75 +
  76 + Scenario: edit an article
  77 + Given I am on Joao Silva's sitemap
  78 + And I follow "Save the whales"
  79 + And I follow "Edit"
  80 + And I fill in "Title" with "My Article edited"
  81 + When I press "Save"
  82 + Then I should be on /joaosilva/my-article-edited
  83 +
  84 + Scenario: cancel button back to article when edit
  85 + Given I am on Joao Silva's sitemap
  86 + And I follow "Save the whales"
  87 + And I follow "Edit"
  88 + When I follow "Cancel"
  89 + Then I should be on /joaosilva/save-the-whales
  90 +
  91 + Scenario: create an article inside a folder
  92 + Given I am on Joao Silva's control panel
  93 + And I follow "Manage Content"
  94 + And I follow "New Folder"
  95 + And I fill in "Title" with "My Folder"
  96 + And I press "Save"
  97 + Then I should be on /joaosilva/my-folder
  98 + When I follow "New article"
  99 + And I follow "Text article with visual editor"
  100 + And I fill in "Title" with "My Article"
  101 + And I press "Save"
  102 + Then I should see "My Article"
  103 + And I should be on /joaosilva/my-folder/my-article
  104 +
  105 + Scenario: cancel button back to folder after giving up creating
  106 + Given I am on Joao Silva's control panel
  107 + And I follow "Manage Content"
  108 + And I follow "New Folder"
  109 + And I fill in "Title" with "My Folder"
  110 + And I press "Save"
  111 + Then I should be on /joaosilva/my-folder
  112 + When I follow "New article"
  113 + And I follow "Text article with visual editor"
  114 + When I follow "Cancel"
  115 + And I should be on /joaosilva/my-folder
  116 +
lib/noosfero.rb
@@ -55,6 +55,8 @@ module Noosfero @@ -55,6 +55,8 @@ module Noosfero
55 def self.url_options 55 def self.url_options
56 if ENV['RAILS_ENV'] == 'development' 56 if ENV['RAILS_ENV'] == 'development'
57 development_url_options 57 development_url_options
  58 + elsif ENV['RAILS_ENV'] == 'cucumber'
  59 + {:host => ''}
58 else 60 else
59 {} 61 {}
60 end 62 end
test/functional/cms_controller_test.rb
@@ -478,29 +478,31 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -478,29 +478,31 @@ class CmsControllerTest &lt; Test::Unit::TestCase
478 assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{f.id}&amp;type=Folder" } 478 assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{f.id}&amp;type=Folder" }
479 end 479 end
480 480
481 - should 'redirect back to index after creating top-level article' do  
482 - post :new, :profile => profile.identifier, :type => 'TextileArticle', :article => { :name => 'test' }  
483 - assert_redirected_to :action => 'index' 481 + should 'redirect to article after creating top-level article' do
  482 + post :new, :profile => profile.identifier, :type => 'TextileArticle', :article => { :name => 'top-level-article' }
  483 +
  484 + assert_redirected_to @profile.articles.find_by_name('top-level-article').url
484 end 485 end
485 486
486 - should 'redirect back to folder after creating article inside it' do 487 + should 'redirect to article after creating article inside a folder' do
487 f = Folder.new(:name => 'f'); profile.articles << f; f.save! 488 f = Folder.new(:name => 'f'); profile.articles << f; f.save!
488 - post :new, :profile => profile.identifier, :type => 'TextileArticle', :parent_id => f.id, :article => { :name => 'test' }  
489 - assert_redirected_to :action => 'view', :id => f.id 489 + post :new, :profile => profile.identifier, :type => 'TextileArticle', :parent_id => f.id, :article => { :name => 'article-inside-folder' }
  490 +
  491 + assert_redirected_to @profile.articles.find_by_name('article-inside-folder').url
490 end 492 end
491 493
492 - should 'redirect back to index after editing top-level article' do  
493 - f = Folder.new(:name => 'f'); profile.articles << f; f.save! 494 + should 'redirect back to article after editing top-level article' do
  495 + f = Folder.new(:name => 'top-level-article'); profile.articles << f; f.save!
494 post :edit, :profile => profile.identifier, :id => f.id 496 post :edit, :profile => profile.identifier, :id => f.id
495 - assert_redirected_to :action => 'index' 497 + assert_redirected_to @profile.articles.find_by_name('top-level-article').url
496 end 498 end
497 499
498 - should 'redirect back to folder after editing article inside it' do 500 + should 'redirect back to article after editing article inside a folder' do
499 f = Folder.new(:name => 'f'); profile.articles << f; f.save! 501 f = Folder.new(:name => 'f'); profile.articles << f; f.save!
500 - a = TextileArticle.create!(:parent => f, :name => 'test', :profile_id => profile.id) 502 + a = TextileArticle.create!(:parent => f, :name => 'article-inside-folder', :profile_id => profile.id)
501 503
502 post :edit, :profile => profile.identifier, :id => a.id 504 post :edit, :profile => profile.identifier, :id => a.id
503 - assert_redirected_to :action => 'view', :id => f.id 505 + assert_redirected_to @profile.articles.find_by_name('article-inside-folder').url
504 end 506 end
505 507
506 should 'point back to index when cancelling creation of top-level article' do 508 should 'point back to index when cancelling creation of top-level article' do
@@ -604,15 +606,15 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -604,15 +606,15 @@ class CmsControllerTest &lt; Test::Unit::TestCase
604 @request.expects(:referer).returns('http://colivre.net/testinguser/myarticle').at_least_once 606 @request.expects(:referer).returns('http://colivre.net/testinguser/myarticle').at_least_once
605 607
606 get :edit, :profile => 'testinguser', :id => article.id 608 get :edit, :profile => 'testinguser', :id => article.id
607 - assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => 'public_view' } 609 + assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => @request.referer }
608 assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => /^https?:\/\/colivre.net\/testinguser\/myarticle/ } 610 assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => /^https?:\/\/colivre.net\/testinguser\/myarticle/ }
609 end 611 end
610 612
611 should 'detect when comming from home page' do 613 should 'detect when comming from home page' do
612 @request.expects(:referer).returns('http://colivre.net/testinguser').at_least_once 614 @request.expects(:referer).returns('http://colivre.net/testinguser').at_least_once
613 get :edit, :profile => 'testinguser', :id => @profile.home_page.id 615 get :edit, :profile => 'testinguser', :id => @profile.home_page.id
614 - assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => 'public_view' }  
615 - assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => /^https?:\/\/colivre.net\/testinguser\/#{@profile.home_page.slug}$/ } 616 + assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => @request.referer }
  617 + assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => @request.referer }
616 end 618 end
617 619
618 should 'go back to public view when saving coming from there' do 620 should 'go back to public view when saving coming from there' do
@@ -625,7 +627,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -625,7 +627,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
625 should 'record as coming from public view when creating article' do 627 should 'record as coming from public view when creating article' do
626 @request.expects(:referer).returns('http://colivre.net/testinguser/testingusers-home-page').at_least_once 628 @request.expects(:referer).returns('http://colivre.net/testinguser/testingusers-home-page').at_least_once
627 get :new, :profile => 'testinguser', :type => 'TextileArticle' 629 get :new, :profile => 'testinguser', :type => 'TextileArticle'
628 - assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => 'public_view' } 630 + assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => @request.referer }
629 assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => 'http://colivre.net/testinguser/testingusers-home-page' } 631 assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => 'http://colivre.net/testinguser/testingusers-home-page' }
630 end 632 end
631 633
@@ -835,17 +837,18 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -835,17 +837,18 @@ class CmsControllerTest &lt; Test::Unit::TestCase
835 assert :tag => 'input', :attributes => {:name => 'article[notify_comments]', :value => 1} 837 assert :tag => 'input', :attributes => {:name => 'article[notify_comments]', :value => 1}
836 end 838 end
837 839
838 - should 'back to control panel after create blog' do 840 + should 'go to blog after create it' do
839 assert_difference Blog, :count do 841 assert_difference Blog, :count do
840 post :new, :type => Blog.name, :profile => profile.identifier, :article => { :name => 'my-blog' }, :back_to => 'control_panel' 842 post :new, :type => Blog.name, :profile => profile.identifier, :article => { :name => 'my-blog' }, :back_to => 'control_panel'
841 - assert_redirected_to :controller => 'profile_editor', :profile => profile.identifier  
842 end 843 end
  844 + assert_redirected_to @profile.articles.find_by_name('my-blog').view_url
843 end 845 end
844 846
845 - should 'back to control panel after config blog' do 847 + should 'back to blog after config blog' do
846 profile.articles << Blog.new(:name => 'my-blog', :profile => profile) 848 profile.articles << Blog.new(:name => 'my-blog', :profile => profile)
847 - post :edit, :profile => profile.identifier, :id => profile.blog.id, :back_to => 'control_panel'  
848 - assert_redirected_to :controller => 'profile_editor', :profile => profile.identifier 849 + post :edit, :profile => profile.identifier, :id => profile.blog.id
  850 +
  851 + assert_redirected_to @profile.articles.find_by_name('my-blog').view_url
849 end 852 end
850 853
851 should 'back to control panel if cancel create blog' do 854 should 'back to control panel if cancel create blog' do
@@ -885,27 +888,26 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -885,27 +888,26 @@ class CmsControllerTest &lt; Test::Unit::TestCase
885 @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}/#{folder.slug}").at_least_once 888 @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}/#{folder.slug}").at_least_once
886 889
887 get :upload_files, :profile => profile.identifier, :parent_id => folder.id 890 get :upload_files, :profile => profile.identifier, :parent_id => folder.id
888 - assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => 'public_view' } 891 + assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => @request.referer }
889 assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => /^https?:\/\/colivre.net\/#{profile.identifier}\/#{folder.slug}/ } 892 assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => /^https?:\/\/colivre.net\/#{profile.identifier}\/#{folder.slug}/ }
890 end 893 end
891 894
892 should 'detect when comming from home page to upload files' do 895 should 'detect when comming from home page to upload files' do
893 folder = Folder.create!(:name => 'testfolder', :profile => profile) 896 folder = Folder.create!(:name => 'testfolder', :profile => profile)
894 - profile.expects(:home_page).returns(folder).at_least_once  
895 -  
896 @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}").at_least_once 897 @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}").at_least_once
897 @controller.stubs(:profile).returns(profile) 898 @controller.stubs(:profile).returns(profile)
898 get :upload_files, :profile => profile.identifier, :parent_id => folder.id 899 get :upload_files, :profile => profile.identifier, :parent_id => folder.id
899 - assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => 'public_view' }  
900 - assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => /^https?:\/\/colivre.net\/#{profile.identifier}\/#{profile.home_page.slug}$/ } 900 + assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => @request.referer }
  901 + assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => @request.referer }
901 end 902 end
902 903
903 should 'go back to public view when upload files coming from there' do 904 should 'go back to public view when upload files coming from there' do
904 folder = Folder.create!(:name => 'test_folder', :profile => profile) 905 folder = Folder.create!(:name => 'test_folder', :profile => profile)
  906 + @request.expects(:referer).returns(folder.view_url).at_least_once
905 907
906 - post :upload_files, :profile => profile.identifier, :parent_id => folder.id, :back_to => 'public_view', :uploaded_files => [fixture_file_upload('files/rails.png', 'image/png')] 908 + post :upload_files, :profile => profile.identifier, :parent_id => folder.id, :back_to => @request.referer, :uploaded_files => [fixture_file_upload('files/rails.png', 'image/png')]
907 assert_template nil 909 assert_template nil
908 - assert_redirected_to folder.url 910 + assert_redirected_to folder.view_url
909 end 911 end
910 912
911 should 'record when coming from public view on edit files with view true' do 913 should 'record when coming from public view on edit files with view true' do
@@ -914,26 +916,25 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -914,26 +916,25 @@ class CmsControllerTest &lt; Test::Unit::TestCase
914 @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}/#{file.slug}?view=true").at_least_once 916 @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}/#{file.slug}?view=true").at_least_once
915 917
916 get :edit, :profile => profile.identifier, :id => file.id 918 get :edit, :profile => profile.identifier, :id => file.id
917 - assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => 'public_view' } 919 + assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => @request.referer }
918 assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => /^https?:\/\/colivre.net\/#{profile.identifier}\/#{file.slug}?.*view=true/ } 920 assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => /^https?:\/\/colivre.net\/#{profile.identifier}\/#{file.slug}?.*view=true/ }
919 end 921 end
920 922
921 should 'detect when comming from home page to edit files with view true' do 923 should 'detect when comming from home page to edit files with view true' do
922 file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) 924 file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'))
923 - profile.expects(:home_page).returns(file).at_least_once  
924 925
925 @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}?view=true").at_least_once 926 @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}?view=true").at_least_once
926 @controller.stubs(:profile).returns(profile) 927 @controller.stubs(:profile).returns(profile)
927 get :edit, :profile => profile.identifier, :id => file.id 928 get :edit, :profile => profile.identifier, :id => file.id
928 - assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => 'public_view' }  
929 - assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => /^https?:\/\/colivre.net\/#{profile.identifier}\/#{profile.home_page.slug}?.*view=true$/ } 929 + assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => @request.referer }
  930 + assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => @request.referer }
930 end 931 end
931 932
932 should 'go back to public view when edit files coming from there with view true' do 933 should 'go back to public view when edit files coming from there with view true' do
933 file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) 934 file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'))
934 @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}/#{file.slug}?view=true").at_least_once 935 @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}/#{file.slug}?view=true").at_least_once
935 936
936 - post :edit, :profile => profile.identifier, :id => file.id, :back_to => 'public_view', :article => {:abstract => 'some description'} 937 + post :edit, :profile => profile.identifier, :id => file.id, :back_to => @request.referer, :article => {:abstract => 'some description'}
937 assert_template nil 938 assert_template nil
938 assert_redirected_to file.url.merge(:view => true) 939 assert_redirected_to file.url.merge(:view => true)
939 end 940 end
@@ -1107,7 +1108,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -1107,7 +1108,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
1107 1108
1108 1109
1109 should 'redirect to media listing when upload files from there' do 1110 should 'redirect to media listing when upload files from there' do
1110 - post :upload_files, :profile => profile.identifier, :back_to => 'media_listing', :uploaded_files => [fixture_file_upload('files/rails.png', 'image/png')] 1111 + post :upload_files, :profile => profile.identifier, :media_listing => true, :uploaded_files => [fixture_file_upload('files/rails.png', 'image/png')]
1111 assert_template nil 1112 assert_template nil
1112 assert_redirected_to :action => 'media_listing' 1113 assert_redirected_to :action => 'media_listing'
1113 end 1114 end
@@ -1115,7 +1116,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -1115,7 +1116,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
1115 should 'redirect to media listing when occur errors when upload files from there' do 1116 should 'redirect to media listing when occur errors when upload files from there' do
1116 file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('files/rails.png', 'image/png')) 1117 file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('files/rails.png', 'image/png'))
1117 1118
1118 - post :upload_files, :profile => profile.identifier, :back_to => 'media_listing', :uploaded_files => [fixture_file_upload('files/rails.png', 'image/png')] 1119 + post :upload_files, :profile => profile.identifier, :media_listing => true, :uploaded_files => [fixture_file_upload('files/rails.png', 'image/png')]
1119 assert_template nil 1120 assert_template nil
1120 assert_redirected_to :action => 'media_listing' 1121 assert_redirected_to :action => 'media_listing'
1121 end 1122 end
test/functional/invite_controller_test.rb
@@ -13,7 +13,7 @@ class InviteControllerTest &lt; ActionController::TestCase @@ -13,7 +13,7 @@ class InviteControllerTest &lt; ActionController::TestCase
13 should 'actually invite manually added address with friend object' do 13 should 'actually invite manually added address with friend object' do
14 assert_difference InviteFriend, :count, 1 do 14 assert_difference InviteFriend, :count, 1 do
15 post :friends, :profile => profile.identifier, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "manual", :mail_template => "click: <url>", :step => 2 15 post :friends, :profile => profile.identifier, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "manual", :mail_template => "click: <url>", :step => 2
16 - assert_redirected_to :controller => 'profile' 16 + assert_redirected_to :controller => 'friends'
17 end 17 end
18 end 18 end
19 19
@@ -83,4 +83,15 @@ class InviteControllerTest &lt; ActionController::TestCase @@ -83,4 +83,15 @@ class InviteControllerTest &lt; ActionController::TestCase
83 assert_response 403 # forbidden 83 assert_response 403 # forbidden
84 end 84 end
85 85
  86 + should 'redirect to friends after invitation if profile is a person' do
  87 + post :friends, :profile => profile.identifier, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "manual", :mail_template => "click: <url>", :step => 2
  88 + assert_redirected_to :controller => 'friends'
  89 + end
  90 +
  91 + should 'redirect to friends after invitation if profile is not a person' do
  92 + community.add_admin(profile)
  93 + post :friends, :profile => community.identifier, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "manual", :mail_template => "click: <url>", :step => 2
  94 + assert_redirected_to :controller => 'profile_members'
  95 + end
  96 +
86 end 97 end
test/functional/profile_controller_test.rb
@@ -574,10 +574,10 @@ class ProfileControllerTest &lt; Test::Unit::TestCase @@ -574,10 +574,10 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
574 community = Community.create!(:name => 'my test community') 574 community = Community.create!(:name => 'my test community')
575 community.add_member(profile) 575 community.add_member(profile)
576 576
577 - @request.session[:return_to] = "/profile/#{community.identifier}/to_go" 577 + @request.expects(:referer).returns("/profile/#{community.identifier}/to_go").at_least_once
578 login_as(profile.identifier) 578 login_as(profile.identifier)
579 579
580 - post :leave, :profile => community.identifier, :confirmation => '1' 580 + post :leave, :profile => community.identifier, :confirmation => '1', :back_to => @request.referer
581 581
582 assert_redirected_to "/profile/#{community.identifier}/to_go" 582 assert_redirected_to "/profile/#{community.identifier}/to_go"
583 end 583 end
@@ -586,30 +586,28 @@ class ProfileControllerTest &lt; Test::Unit::TestCase @@ -586,30 +586,28 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
586 community = Community.create!(:name => 'my test community') 586 community = Community.create!(:name => 'my test community')
587 login_as(profile.identifier) 587 login_as(profile.identifier)
588 588
589 - assert_nil @request.session[:return_to]  
590 - @request.expects(:referer).returns("/profile/redirect_to") 589 + @request.expects(:referer).returns("/profile/redirect_to").at_least_once
591 590
592 get :leave, :profile => community.identifier 591 get :leave, :profile => community.identifier
593 592
594 - assert_equal '/profile/redirect_to', @request.session[:return_to] 593 + assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => @request.referer }
595 end 594 end
596 595
597 should 'store referer location when request join via get' do 596 should 'store referer location when request join via get' do
598 community = Community.create!(:name => 'my test community') 597 community = Community.create!(:name => 'my test community')
599 login_as(profile.identifier) 598 login_as(profile.identifier)
600 599
601 - assert_nil @request.session[:return_to]  
602 - @request.expects(:referer).returns("/profile/redirect_to").at_least_once 600 + @request.session[:before_join] = "/profile/redirect_to"
603 601
604 get :join, :profile => community.identifier 602 get :join, :profile => community.identifier
605 603
606 - assert_equal '/profile/redirect_to', @request.session[:return_to] 604 + assert_equal '/profile/redirect_to', @request.session[:before_join]
607 end 605 end
608 606
609 should 'redirect to stored location after join community' do 607 should 'redirect to stored location after join community' do
610 community = Community.create!(:name => 'my test community') 608 community = Community.create!(:name => 'my test community')
611 609
612 - @request.session[:return_to] = "/profile/#{community.identifier}/to_go" 610 + @request.expects(:referer).returns("/profile/#{community.identifier}/to_go")
613 login_as(profile.identifier) 611 login_as(profile.identifier)
614 612
615 post :join, :profile => community.identifier, :confirmation => '1' 613 post :join, :profile => community.identifier, :confirmation => '1'
@@ -630,7 +628,7 @@ class ProfileControllerTest &lt; Test::Unit::TestCase @@ -630,7 +628,7 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
630 should 'redirect to location before login after join community' do 628 should 'redirect to location before login after join community' do
631 community = Community.create!(:name => 'my test community') 629 community = Community.create!(:name => 'my test community')
632 630
633 - @request.session[:return_to] = "/profile/#{community.identifier}/to_go" 631 + @request.expects(:referer).returns("/profile/#{community.identifier}/to_go")
634 login_as(profile.identifier) 632 login_as(profile.identifier)
635 633
636 post :join, :profile => community.identifier, :confirmation => '1' 634 post :join, :profile => community.identifier, :confirmation => '1'
test/integration/manage_documents_test.rb
@@ -29,7 +29,7 @@ class ManageDocumentsTest &lt; ActionController::IntegrationTest @@ -29,7 +29,7 @@ class ManageDocumentsTest &lt; ActionController::IntegrationTest
29 assert_response :redirect 29 assert_response :redirect
30 follow_redirect! 30 follow_redirect!
31 a = Article.find_by_path('my-article') 31 a = Article.find_by_path('my-article')
32 - assert_equal "/myprofile/myuser/cms", path 32 + assert_equal "/myuser/#{a.slug}", path
33 end 33 end
34 34
35 def test_update_of_an_existing_article 35 def test_update_of_an_existing_article
@@ -62,7 +62,7 @@ class ManageDocumentsTest &lt; ActionController::IntegrationTest @@ -62,7 +62,7 @@ class ManageDocumentsTest &lt; ActionController::IntegrationTest
62 assert_response :redirect 62 assert_response :redirect
63 follow_redirect! 63 follow_redirect!
64 a = Article.find_by_path('my-article') 64 a = Article.find_by_path('my-article')
65 - assert_equal "/myprofile/myuser/cms", path 65 + assert_equal "/myuser/#{a.slug}", path
66 end 66 end
67 67
68 def test_removing_an_article 68 def test_removing_an_article