cleaned up craziness in users and likes routing, fixed #961
This commit is contained in:
parent
33c013633f
commit
56a6f0e43b
20 changed files with 56 additions and 60 deletions
|
|
@ -22,7 +22,7 @@ class ProfilesController < ApplicationController
|
||||||
if params[:getting_started]
|
if params[:getting_started]
|
||||||
redirect_to getting_started_path(:step => params[:getting_started].to_i+1)
|
redirect_to getting_started_path(:step => params[:getting_started].to_i+1)
|
||||||
else
|
else
|
||||||
redirect_to current_user.person
|
redirect_to edit_profile_path
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
flash[:error] = I18n.t 'profiles.update.failed'
|
flash[:error] = I18n.t 'profiles.update.failed'
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class UsersController < ApplicationController
|
||||||
render :nothing => true, :status => 204
|
render :nothing => true, :status => 204
|
||||||
}
|
}
|
||||||
format.all{
|
format.all{
|
||||||
redirect_to edit_user_path(@user)
|
redirect_to edit_user_path
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -110,17 +110,6 @@ module ApplicationHelper
|
||||||
timeago(obj.created_at)
|
timeago(obj.created_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def person_url(person)
|
|
||||||
case person.class.to_s
|
|
||||||
when "User"
|
|
||||||
user_path(person)
|
|
||||||
when "Person"
|
|
||||||
person_path(person)
|
|
||||||
else
|
|
||||||
I18n.t('application.helper.unknown_person')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def profile_photo(person)
|
def profile_photo(person)
|
||||||
person_image_link(person, :size => :thumb_large, :to => :photos)
|
person_image_link(person, :size => :thumb_large, :to => :photos)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
= owner_image_tag(:thumb_small)
|
= owner_image_tag(:thumb_small)
|
||||||
= link_to current_user.name, '#'
|
= link_to current_user.name, '#'
|
||||||
%li= link_to t('.profile'), current_user.person
|
%li= link_to t('.profile'), current_user.person
|
||||||
%li= link_to t('.settings'), edit_user_path(current_user)
|
%li= link_to t('.settings'), edit_user_path
|
||||||
%li= link_to t('.logout'), destroy_user_session_path
|
%li= link_to t('.logout'), destroy_user_session_path
|
||||||
|
|
||||||
-unless @landing_page
|
-unless @landing_page
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,5 @@
|
||||||
= image_tag attachments['logo_caps.png'].url, :alt => "DIASPORA"
|
= image_tag attachments['logo_caps.png'].url, :alt => "DIASPORA"
|
||||||
#container
|
#container
|
||||||
= yield
|
= yield
|
||||||
%a{:href => "http://#{ AppConfig[:pod_uri].host}/users/#{@receiver.id}/edit"}
|
%a{:href => "#{AppConfig[:pod_uri].scheme}://#{AppConfig[:pod_uri].host}#{edit_user_path}"}
|
||||||
= t('notifier.manage_your_email_settings')
|
= t('notifier.manage_your_email_settings')
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
!= yield
|
!= yield
|
||||||
!= t('notifier.manage_your_email_settings')
|
!= t('notifier.manage_your_email_settings')
|
||||||
!= "www.#{ AppConfig[:pod_uri].host}/users/#{@receiver.id}/edit"
|
!= "#{AppConfig[:pod_uri].scheme}://#{AppConfig[:pod_uri].host}#{edit_user_path}"
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,9 @@
|
||||||
// TODO(likes)
|
// TODO(likes)
|
||||||
/- if (defined?(current_user) && !current_user.liked?(@parent))
|
/- if (defined?(current_user) && !current_user.liked?(@parent))
|
||||||
/ %span.like_links
|
/ %span.like_links
|
||||||
/ = link_to t('shared.stream_element.like'), {:controller => "likes", :action => "create", :positive => 'true', :post_id => @parent.id }, :class => "like_it", :remote => true
|
/ = link_to t('shared.stream_element.like'), likes_path(:positive => 'true', :post_id => @parent.id), :method => :post, :class => "like_it", :remote => true
|
||||||
/ |
|
/ |
|
||||||
/ = link_to t('shared.stream_element.dislike'), {:controller => "likes", :action => "create", :positive => 'false', :post_id => @parent.id }, :class => "dislike_it", :remote => true
|
/ = link_to t('shared.stream_element.dislike'), likes_path(:positive => 'false', :post_id => @parent.id), :method => :post, :class => "dislike_it", :remote => true
|
||||||
|
|
||||||
%div{:data=>{:guid=>@parent.id}}
|
%div{:data=>{:guid=>@parent.id}}
|
||||||
.likes_container
|
.likes_container
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= t('.edit_profile')
|
= t('.edit_profile')
|
||||||
|
|
||||||
= form_tag profile_path(profile), :method => :put, :multipart => true, :id => 'update_profile_form' do
|
= form_tag profile_path, :method => :put, :multipart => true, :id => 'update_profile_form' do
|
||||||
= render 'profiles/edit_public', :profile => profile, :aspect => aspect, :person => person
|
= render 'profiles/edit_public', :profile => profile, :aspect => aspect, :person => person
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,7 @@
|
||||||
#section_header
|
#section_header
|
||||||
%h2
|
%h2
|
||||||
= t('settings')
|
= t('settings')
|
||||||
%ul#settings_nav
|
= render 'shared/settings_nav'
|
||||||
%li=link_to t('profile'), edit_profile_path
|
|
||||||
%li=link_to t('account'), edit_user_path(current_user)
|
|
||||||
%li=link_to t('_services'), services_path
|
|
||||||
|
|
||||||
.span-12.prepend-5.last
|
.span-12.prepend-5.last
|
||||||
- content_for :submit_block do
|
- content_for :submit_block do
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,7 @@
|
||||||
#section_header
|
#section_header
|
||||||
%h2
|
%h2
|
||||||
= t('settings')
|
= t('settings')
|
||||||
%ul#settings_nav
|
= render 'shared/settings_nav'
|
||||||
%li=link_to t('profile'), edit_profile_path
|
|
||||||
%li=link_to t('account'), edit_user_path(current_user)
|
|
||||||
%li=link_to t('_services'), services_path
|
|
||||||
|
|
||||||
.span-19.prepend-5.last
|
.span-19.prepend-5.last
|
||||||
%h2
|
%h2
|
||||||
|
|
|
||||||
4
app/views/shared/_settings_nav.haml
Normal file
4
app/views/shared/_settings_nav.haml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
%ul#settings_nav
|
||||||
|
%li=link_to t('profile'), edit_profile_path
|
||||||
|
%li=link_to t('account'), edit_user_path
|
||||||
|
%li=link_to t('_services'), services_path
|
||||||
|
|
@ -37,9 +37,9 @@
|
||||||
/- if (defined?(current_user) && !current_user.liked?(post))
|
/- if (defined?(current_user) && !current_user.liked?(post))
|
||||||
/ %span.like_links
|
/ %span.like_links
|
||||||
/ |
|
/ |
|
||||||
/ = link_to t('.like'), {:controller => "likes", :action => "create", :positive => 'true', :post_id => post.id }, :class => "like_it", :remote => true
|
/ = link_to t('.like'), likes_path(:positive => 'true', :post_id => post.id ), :method => :post, :class => "like_it", :remote => true
|
||||||
/ |
|
/ |
|
||||||
/ = link_to t('.dislike'), {:controller => "likes", :action => "create", :positive => 'false', :post_id => post.id }, :class => "dislike_it", :remote => true
|
/ = link_to t('.dislike'), likes_path(:positive => 'false', :post_id => post.id), :method => :post, :class => "dislike_it", :remote => true
|
||||||
|
|
||||||
/.likes_container
|
/.likes_container
|
||||||
/ = render "likes/likes", :post_id => post.id, :likes => post.likes, :dislikes => post.dislikes, :current_user => current_user
|
/ = render "likes/likes", :post_id => post.id, :likes => post.likes, :dislikes => post.dislikes, :current_user => current_user
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,7 @@
|
||||||
#section_header
|
#section_header
|
||||||
%h2
|
%h2
|
||||||
= t('settings')
|
= t('settings')
|
||||||
%ul#settings_nav
|
= render 'shared/settings_nav'
|
||||||
%li=link_to t('profile'), edit_profile_path
|
|
||||||
%li=link_to t('account'), edit_user_path(current_user)
|
|
||||||
%li=link_to t('_services'), services_path
|
|
||||||
|
|
||||||
.span-12.prepend-5.last
|
.span-12.prepend-5.last
|
||||||
%h2
|
%h2
|
||||||
|
|
@ -35,7 +32,7 @@
|
||||||
|
|
||||||
%h3
|
%h3
|
||||||
= t('.change_password')
|
= t('.change_password')
|
||||||
= form_for @user do |f|
|
= form_for 'user', :url => user_path, :html => { :method => :put } do |f|
|
||||||
= f.error_messages
|
= f.error_messages
|
||||||
|
|
||||||
%p
|
%p
|
||||||
|
|
@ -49,7 +46,7 @@
|
||||||
= f.password_field :password_confirmation
|
= f.password_field :password_confirmation
|
||||||
|
|
||||||
.submit_block
|
.submit_block
|
||||||
= link_to t('cancel'), edit_user_path(current_user)
|
= link_to t('cancel'), edit_user_path
|
||||||
= t('or')
|
= t('or')
|
||||||
= f.submit t('.change_password')
|
= f.submit t('.change_password')
|
||||||
|
|
||||||
|
|
@ -60,7 +57,7 @@
|
||||||
|
|
||||||
%h3
|
%h3
|
||||||
= t('.change_language')
|
= t('.change_language')
|
||||||
= form_for @user do |f|
|
= form_for 'user', :url => user_path, :html => { :method => :put } do |f|
|
||||||
= f.error_messages
|
= f.error_messages
|
||||||
|
|
||||||
%p
|
%p
|
||||||
|
|
@ -74,7 +71,7 @@
|
||||||
|
|
||||||
%h3
|
%h3
|
||||||
= t('.receive_email_notifications')
|
= t('.receive_email_notifications')
|
||||||
= form_for @user do |f|
|
= form_for 'user', :url => user_path, :html => { :method => :put } do |f|
|
||||||
= f.error_messages
|
= f.error_messages
|
||||||
|
|
||||||
= f.fields_for :email_preferences do |type|
|
= f.fields_for :email_preferences do |type|
|
||||||
|
|
@ -127,6 +124,6 @@
|
||||||
.span-5.last
|
.span-5.last
|
||||||
%h3
|
%h3
|
||||||
= t('.close_account')
|
= t('.close_account')
|
||||||
= link_to t('.close_account'), current_user,
|
= link_to t('.close_account'), user_path,
|
||||||
:confirm => t('are_you_sure'), :method => :delete,
|
:confirm => t('are_you_sure'), :method => :delete,
|
||||||
:class => "button"
|
:class => "button"
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@ Diaspora::Application.routes.draw do
|
||||||
resources :status_messages, :only => [:new, :create, :destroy, :show]
|
resources :status_messages, :only => [:new, :create, :destroy, :show]
|
||||||
resources :comments, :only => [:create]
|
resources :comments, :only => [:create]
|
||||||
resources :requests, :only => [:destroy, :create]
|
resources :requests, :only => [:destroy, :create]
|
||||||
match '/likes' => 'likes#create'
|
resource :likes, :only => [:create]
|
||||||
resources :likes, :only => [:create]
|
|
||||||
|
|
||||||
match 'tags/:name' => 'tags#show'
|
match 'tags/:name' => 'tags#show'
|
||||||
resources :tags, :only => [:show]
|
resources :tags, :only => [:show]
|
||||||
|
|
@ -45,6 +44,12 @@ Diaspora::Application.routes.draw do
|
||||||
match 'photos/make_profile_photo' => 'photos#make_profile_photo'
|
match 'photos/make_profile_photo' => 'photos#make_profile_photo'
|
||||||
resources :photos, :except => [:index]
|
resources :photos, :except => [:index]
|
||||||
|
|
||||||
|
resource :user, :only => [:edit, :update, :destroy]
|
||||||
|
|
||||||
|
# This is a hack to overide a route created by devise.
|
||||||
|
# I couldn't find anything in devise to skip that route, see Bug #961
|
||||||
|
match '/users/edit' => redirect('/user/edit')
|
||||||
|
|
||||||
devise_for :users, :controllers => {:registrations => "registrations",
|
devise_for :users, :controllers => {:registrations => "registrations",
|
||||||
:password => "devise/passwords",
|
:password => "devise/passwords",
|
||||||
:sessions => "sessions",
|
:sessions => "sessions",
|
||||||
|
|
@ -61,7 +66,6 @@ Diaspora::Application.routes.draw do
|
||||||
match 'users/export', :to => 'users#export'
|
match 'users/export', :to => 'users#export'
|
||||||
match 'users/export_photos', :to => 'users#export_photos'
|
match 'users/export_photos', :to => 'users#export_photos'
|
||||||
match 'login' => redirect('/users/sign_in')
|
match 'login' => redirect('/users/sign_in')
|
||||||
resources :users, :except => [:create, :new, :show]
|
|
||||||
|
|
||||||
match 'aspects/move_contact', :to => 'aspects#move_contact', :as => 'move_contact'
|
match 'aspects/move_contact', :to => 'aspects#move_contact', :as => 'move_contact'
|
||||||
match 'aspects/add_to_aspect', :to => 'aspects#add_to_aspect', :as => 'add_to_aspect'
|
match 'aspects/add_to_aspect', :to => 'aspects#add_to_aspect', :as => 'add_to_aspect'
|
||||||
|
|
|
||||||
|
|
@ -11,22 +11,23 @@ Feature: editing your profile
|
||||||
Scenario: editing gender with a textbox
|
Scenario: editing gender with a textbox
|
||||||
When I fill in "profile_gender" with "Fearless"
|
When I fill in "profile_gender" with "Fearless"
|
||||||
And I press "Update Profile"
|
And I press "Update Profile"
|
||||||
Then I should be on my profile page
|
Then I should be on my edit profile page
|
||||||
And I should see "Profile updated"
|
And I should see "Profile updated"
|
||||||
And I should see "Fearless"
|
And the "profile_gender" field should contain "Fearless"
|
||||||
|
|
||||||
Scenario: editing name
|
Scenario: editing name
|
||||||
When I fill in "profile_first_name" with "Boba"
|
When I fill in "profile_first_name" with "Boba"
|
||||||
And I fill in "profile_last_name" with "Fett"
|
And I fill in "profile_last_name" with "Fett"
|
||||||
And I press "Update Profile"
|
And I press "Update Profile"
|
||||||
Then I should be on my profile page
|
Then I should be on my edit profile page
|
||||||
And I should see "Profile updated"
|
And I should see "Profile updated"
|
||||||
And I should see "Boba Fett"
|
And the "profile_first_name" field should contain "Boba"
|
||||||
|
And the "profile_last_name" field should contain "Fett"
|
||||||
|
|
||||||
Scenario: edit bio
|
Scenario: edit bio
|
||||||
When I fill in "profile_bio" with "This is a bio"
|
When I fill in "profile_bio" with "This is a bio"
|
||||||
And I press "Update Profile"
|
And I press "Update Profile"
|
||||||
Then I should be on my profile page
|
Then I should be on my edit profile page
|
||||||
And I should see "Profile updated"
|
And I should see "Profile updated"
|
||||||
And I should see "This is a bio"
|
And I should see "This is a bio"
|
||||||
|
|
||||||
|
|
@ -35,6 +36,8 @@ Feature: editing your profile
|
||||||
And I select "November" from "profile_date_month"
|
And I select "November" from "profile_date_month"
|
||||||
And I select "30" from "profile_date_day"
|
And I select "30" from "profile_date_day"
|
||||||
And I press "Update Profile"
|
And I press "Update Profile"
|
||||||
Then I should be on my profile page
|
Then I should be on my edit profile page
|
||||||
And I should see "Profile updated"
|
And I should see "Profile updated"
|
||||||
Then I should see "November 30 1986"
|
And the "profile_date_year" field should be filled with "1986"
|
||||||
|
And the "profile_date_month" field should be filled with "November"
|
||||||
|
And the "profile_date_day" field should be filled with "30"
|
||||||
|
|
|
||||||
|
|
@ -165,4 +165,17 @@ end
|
||||||
|
|
||||||
When /^I click on the add contact button$/ do
|
When /^I click on the add contact button$/ do
|
||||||
page.execute_script("$('.add_contact a').click();")
|
page.execute_script("$('.add_contact a').click();")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^the "([^"]*)" field(?: within "([^"]*)")? should be filled with "([^"]*)"$/ do |field, selector, value|
|
||||||
|
with_scope(selector) do
|
||||||
|
field = find_field(field)
|
||||||
|
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
||||||
|
field_value = field_value.first if field_value.is_a? Array
|
||||||
|
if field_value.respond_to? :should
|
||||||
|
field_value.should == value
|
||||||
|
else
|
||||||
|
assert_equal(value, field_value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ module NavigationHelpers
|
||||||
when /^"([^\"]*)"'s page$/
|
when /^"([^\"]*)"'s page$/
|
||||||
person_path(User.find_by_email($1).person)
|
person_path(User.find_by_email($1).person)
|
||||||
when /^my account settings page$/
|
when /^my account settings page$/
|
||||||
edit_user_path(@me)
|
edit_user_path
|
||||||
when /^the photo page for "([^\"]*)"'s post "([^\"]*)"$/
|
when /^the photo page for "([^\"]*)"'s post "([^\"]*)"$/
|
||||||
photo_path(User.find_by_email($1).posts.find_by_text($2))
|
photo_path(User.find_by_email($1).posts.find_by_text($2))
|
||||||
when /^"(\/.*)"/
|
when /^"(\/.*)"/
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ $(document).ready(function(){
|
||||||
|
|
||||||
function performAspectUpdate(home){
|
function performAspectUpdate(home){
|
||||||
// update the open aspects in the user
|
// update the open aspects in the user
|
||||||
updateURL = "/users/me";
|
updateURL = "/user";
|
||||||
updateURL += '?';
|
updateURL += '?';
|
||||||
if(home == 'home'){
|
if(home == 'home'){
|
||||||
updateURL += 'user[a_ids][]=home';
|
updateURL += 'user[a_ids][]=home';
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ describe UsersController do
|
||||||
|
|
||||||
it 'redirects to the user edit page' do
|
it 'redirects to the user edit page' do
|
||||||
put :update, @params
|
put :update, @params
|
||||||
response.should redirect_to edit_user_path(@user)
|
response.should redirect_to edit_user_path
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'responds with a 204 on a js request' do
|
it 'responds with a 204 on a js request' do
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,6 @@ describe ApplicationHelper do
|
||||||
@person = Factory.create(:person)
|
@person = Factory.create(:person)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should provide a correct show path for a given person" do
|
|
||||||
person_url(@person).should == "/people/#{@person.id}"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should provide a correct show path for a given user" do
|
|
||||||
person_url(@user).should == "/users/#{@user.id}"
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#object_path" do
|
describe "#object_path" do
|
||||||
it "returns an empty string if object is nil" do
|
it "returns an empty string if object is nil" do
|
||||||
object_path(nil).should == ""
|
object_path(nil).should == ""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue