diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 5306ed1c4..9125e4630 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -22,7 +22,7 @@ class ProfilesController < ApplicationController if params[:getting_started] redirect_to getting_started_path(:step => params[:getting_started].to_i+1) else - redirect_to current_user.person + redirect_to edit_profile_path end else flash[:error] = I18n.t 'profiles.update.failed' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6224ab886..f0a8944ab 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -58,7 +58,7 @@ class UsersController < ApplicationController render :nothing => true, :status => 204 } format.all{ - redirect_to edit_user_path(@user) + redirect_to edit_user_path } end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c2be55c13..d99e35036 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -110,17 +110,6 @@ module ApplicationHelper timeago(obj.created_at) 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) person_image_link(person, :size => :thumb_large, :to => :photos) end diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 136f20e18..aba33c3de 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -40,7 +40,7 @@ = owner_image_tag(:thumb_small) = link_to current_user.name, '#' %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 -unless @landing_page diff --git a/app/views/layouts/notifier.html.haml b/app/views/layouts/notifier.html.haml index ee06ff928..51ad81af3 100644 --- a/app/views/layouts/notifier.html.haml +++ b/app/views/layouts/notifier.html.haml @@ -8,5 +8,5 @@ = image_tag attachments['logo_caps.png'].url, :alt => "DIASPORA" #container = 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') diff --git a/app/views/layouts/notifier.text.haml b/app/views/layouts/notifier.text.haml index a4c5a6d50..5321fe644 100644 --- a/app/views/layouts/notifier.text.haml +++ b/app/views/layouts/notifier.text.haml @@ -1,3 +1,3 @@ != yield != 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}" diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 3c31ebf73..559fc0d3f 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -69,9 +69,9 @@ // TODO(likes) /- if (defined?(current_user) && !current_user.liked?(@parent)) / %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}} .likes_container diff --git a/app/views/profiles/_edit.html.haml b/app/views/profiles/_edit.html.haml index fe0ab2b76..dd826be05 100644 --- a/app/views/profiles/_edit.html.haml +++ b/app/views/profiles/_edit.html.haml @@ -5,7 +5,7 @@ - content_for :page_title do = 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 %hr diff --git a/app/views/profiles/edit.html.haml b/app/views/profiles/edit.html.haml index bea1de098..2413fa95b 100644 --- a/app/views/profiles/edit.html.haml +++ b/app/views/profiles/edit.html.haml @@ -6,10 +6,7 @@ #section_header %h2 = t('settings') - %ul#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 + = render 'shared/settings_nav' .span-12.prepend-5.last - content_for :submit_block do diff --git a/app/views/services/index.html.haml b/app/views/services/index.html.haml index 107767fdc..881481d2c 100644 --- a/app/views/services/index.html.haml +++ b/app/views/services/index.html.haml @@ -8,10 +8,7 @@ #section_header %h2 = t('settings') - %ul#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 + = render 'shared/settings_nav' .span-19.prepend-5.last %h2 diff --git a/app/views/shared/_settings_nav.haml b/app/views/shared/_settings_nav.haml new file mode 100644 index 000000000..1a4e99171 --- /dev/null +++ b/app/views/shared/_settings_nav.haml @@ -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 diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 5a6f0b981..f4946eb77 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -37,9 +37,9 @@ /- if (defined?(current_user) && !current_user.liked?(post)) / %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 / = render "likes/likes", :post_id => post.id, :likes => post.likes, :dislikes => post.dislikes, :current_user => current_user diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 4a67322ef..2124c4d39 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -8,10 +8,7 @@ #section_header %h2 = t('settings') - %ul#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 + = render 'shared/settings_nav' .span-12.prepend-5.last %h2 @@ -35,7 +32,7 @@ %h3 = t('.change_password') - = form_for @user do |f| + = form_for 'user', :url => user_path, :html => { :method => :put } do |f| = f.error_messages %p @@ -49,7 +46,7 @@ = f.password_field :password_confirmation .submit_block - = link_to t('cancel'), edit_user_path(current_user) + = link_to t('cancel'), edit_user_path = t('or') = f.submit t('.change_password') @@ -60,7 +57,7 @@ %h3 = t('.change_language') - = form_for @user do |f| + = form_for 'user', :url => user_path, :html => { :method => :put } do |f| = f.error_messages %p @@ -74,7 +71,7 @@ %h3 = t('.receive_email_notifications') - = form_for @user do |f| + = form_for 'user', :url => user_path, :html => { :method => :put } do |f| = f.error_messages = f.fields_for :email_preferences do |type| @@ -127,6 +124,6 @@ .span-5.last %h3 = t('.close_account') - = link_to t('.close_account'), current_user, + = link_to t('.close_account'), user_path, :confirm => t('are_you_sure'), :method => :delete, :class => "button" diff --git a/config/routes.rb b/config/routes.rb index 7a7a1a2c9..a34d178e1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,8 +6,7 @@ Diaspora::Application.routes.draw do resources :status_messages, :only => [:new, :create, :destroy, :show] resources :comments, :only => [:create] resources :requests, :only => [:destroy, :create] - match '/likes' => 'likes#create' - resources :likes, :only => [:create] + resource :likes, :only => [:create] match 'tags/:name' => 'tags#show' resources :tags, :only => [:show] @@ -45,6 +44,12 @@ Diaspora::Application.routes.draw do match 'photos/make_profile_photo' => 'photos#make_profile_photo' 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", :password => "devise/passwords", :sessions => "sessions", @@ -61,7 +66,6 @@ Diaspora::Application.routes.draw do match 'users/export', :to => 'users#export' match 'users/export_photos', :to => 'users#export_photos' 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/add_to_aspect', :to => 'aspects#add_to_aspect', :as => 'add_to_aspect' diff --git a/features/edits_profile.feature b/features/edits_profile.feature index 86d27dc17..0a9789615 100644 --- a/features/edits_profile.feature +++ b/features/edits_profile.feature @@ -11,22 +11,23 @@ Feature: editing your profile Scenario: editing gender with a textbox When I fill in "profile_gender" with "Fearless" 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 "Fearless" + And the "profile_gender" field should contain "Fearless" Scenario: editing name When I fill in "profile_first_name" with "Boba" And I fill in "profile_last_name" with "Fett" 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 "Boba Fett" + And the "profile_first_name" field should contain "Boba" + And the "profile_last_name" field should contain "Fett" Scenario: edit bio When I fill in "profile_bio" with "This is a bio" 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 "This is a bio" @@ -35,6 +36,8 @@ Feature: editing your profile And I select "November" from "profile_date_month" And I select "30" from "profile_date_day" 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" - 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" diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index 210f9e834..9ff8a9e40 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -165,4 +165,17 @@ end When /^I click on the add contact button$/ do page.execute_script("$('.add_contact a').click();") -end \ No newline at end of file +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 diff --git a/features/support/paths.rb b/features/support/paths.rb index d2043b231..78dbb649f 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -26,7 +26,7 @@ module NavigationHelpers when /^"([^\"]*)"'s page$/ person_path(User.find_by_email($1).person) when /^my account settings page$/ - edit_user_path(@me) + edit_user_path when /^the photo page for "([^\"]*)"'s post "([^\"]*)"$/ photo_path(User.find_by_email($1).posts.find_by_text($2)) when /^"(\/.*)"/ diff --git a/public/javascripts/aspect-filters.js b/public/javascripts/aspect-filters.js index f1f9e58b3..53f1de66b 100644 --- a/public/javascripts/aspect-filters.js +++ b/public/javascripts/aspect-filters.js @@ -107,7 +107,7 @@ $(document).ready(function(){ function performAspectUpdate(home){ // update the open aspects in the user - updateURL = "/users/me"; + updateURL = "/user"; updateURL += '?'; if(home == 'home'){ updateURL += 'user[a_ids][]=home'; diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 51d490664..03e5b2388 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -50,7 +50,7 @@ describe UsersController do it 'redirects to the user edit page' do put :update, @params - response.should redirect_to edit_user_path(@user) + response.should redirect_to edit_user_path end it 'responds with a 204 on a js request' do diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index e8932e2c1..74f1fdc6b 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -10,14 +10,6 @@ describe ApplicationHelper do @person = Factory.create(:person) 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 it "returns an empty string if object is nil" do object_path(nil).should == ""