Merge branch 'master' into getting-started
Conflicts: app/controllers/users_controller.rb app/views/users/_account.haml app/views/users/_profile.haml
This commit is contained in:
commit
385e1673ab
21 changed files with 261 additions and 259 deletions
|
|
@ -20,7 +20,7 @@ You can find an introduction to the source code [here](http://github.com/diaspor
|
|||
Bugs and pending features are on our [issue tracker](http://bugs.joindiaspora.com). Here are a few good places to start:
|
||||
|
||||
- Run "rake spec" to run our [Rspec](http://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-part-i/)
|
||||
unit test suite. Take a look at the pending specs, make one pass!
|
||||
unit test suite. [Here](http://github.com/diaspora/diaspora/wiki/Introduction-to-Our-Rspec-Convention) is an introduction to our Rspec convention. Take a look at the pending specs, make one pass!
|
||||
|
||||
- Run "rake cucumber" to run our [Cucumber](http://rubylearning.com/blog/2010/10/05/outside-in-development/)
|
||||
integration test suite. As you can see, we need more integration tests. Pick a feature and write one!
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ class PeopleController < ApplicationController
|
|||
@profile = @person.profile
|
||||
@aspects_with_person = current_user.aspects_with_person(@person)
|
||||
@posts = current_user.visible_posts(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
|
||||
@latest_status_message = current_user.raw_visible_posts.find_all_by__type_and_person_id("StatusMessage", params[:id]).last
|
||||
@post_count = @posts.count
|
||||
respond_with @person
|
||||
end
|
||||
end
|
||||
|
|
@ -34,4 +32,42 @@ class PeopleController < ApplicationController
|
|||
respond_with :location => root_url
|
||||
end
|
||||
|
||||
def edit
|
||||
@aspect = :person_edit
|
||||
@person = current_user.person
|
||||
@profile = @person.profile
|
||||
@photos = current_user.visible_posts(:person_id => @person.id, :_type => 'Photo').paginate :page => params[:page], :order => 'created_at DESC'
|
||||
end
|
||||
|
||||
def update
|
||||
prep_image_url(params[:person])
|
||||
|
||||
if current_user.update_profile params[:person][:profile]
|
||||
flash[:notice] = "Profile updated"
|
||||
else
|
||||
flash[:error] = "Failed to update profile"
|
||||
end
|
||||
|
||||
if params[:getting_started]
|
||||
redirect_to getting_started_path(params[:getting_started].to_i+1)
|
||||
else
|
||||
redirect_to edit_person_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def prep_image_url(params)
|
||||
url = APP_CONFIG[:pod_url].dup
|
||||
url.chop! if APP_CONFIG[:pod_url][-1,1] == '/'
|
||||
if params[:profile][:image_url].empty?
|
||||
params[:profile].delete(:image_url)
|
||||
else
|
||||
if /^http:\/\// =~ params[:profile][:image_url]
|
||||
params[:profile][:image_url] = params[:profile][:image_url]
|
||||
else
|
||||
params[:profile][:image_url] = url + params[:profile][:image_url]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@ class UsersController < ApplicationController
|
|||
def edit
|
||||
@aspect = :user_edit
|
||||
@user = current_user
|
||||
@person = @user.person
|
||||
@profile = @user.person.profile
|
||||
@photos = current_user.visible_posts(:person_id => current_user.person.id, :_type => 'Photo').paginate :page => params[:page], :order => 'created_at DESC'
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
@ -32,23 +29,11 @@ class UsersController < ApplicationController
|
|||
else
|
||||
flash[:error] = "Password Change Failed"
|
||||
end
|
||||
else
|
||||
prep_image_url(params[:user])
|
||||
if @user.update_profile params[:user][:profile]
|
||||
flash[:notice] = "Profile updated"
|
||||
else
|
||||
flash[:error] = "Failed to update profile"
|
||||
end
|
||||
end
|
||||
|
||||
if params[:getting_started]
|
||||
redirect_to getting_started_path(params[:getting_started].to_i+1)
|
||||
else
|
||||
redirect_to edit_user_path(@user)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
current_user.destroy
|
||||
sign_out current_user
|
||||
|
|
@ -73,6 +58,7 @@ class UsersController < ApplicationController
|
|||
def getting_started
|
||||
@aspect = :getting_started
|
||||
@user = current_user
|
||||
@person = @user.person
|
||||
@profile = current_user.profile
|
||||
@photos = current_user.visible_posts(:person_id => current_user.person.id, :_type => 'Photo').paginate :page => params[:page], :order => 'created_at DESC'
|
||||
|
||||
|
|
@ -118,19 +104,5 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
|
||||
private
|
||||
def prep_image_url(params)
|
||||
url = APP_CONFIG[:pod_url].dup
|
||||
url.chop! if APP_CONFIG[:pod_url][-1,1] == '/'
|
||||
if params[:profile][:image_url].empty?
|
||||
params[:profile].delete(:image_url)
|
||||
else
|
||||
if /^http:\/\// =~ params[:profile][:image_url]
|
||||
params[:profile][:image_url] = params[:profile][:image_url]
|
||||
else
|
||||
params[:profile][:image_url] = url + params[:profile][:image_url]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ class Request
|
|||
validates_presence_of :destination_url, :callback_url
|
||||
before_validation :clean_link
|
||||
|
||||
scope :for_user, lambda{ |user| where(:destination_url => user.person.receive_url) }
|
||||
|
||||
def self.instantiate(options = {})
|
||||
person = options[:from]
|
||||
self.new(:destination_url => options[:to],
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ class User
|
|||
key :invites, Integer, :default => 5
|
||||
key :invitation_token, String
|
||||
key :invitation_sent_at, DateTime
|
||||
key :inviter_ids, Array
|
||||
key :friend_ids, Array
|
||||
key :pending_request_ids, Array
|
||||
key :visible_post_ids, Array
|
||||
key :visible_person_ids, Array
|
||||
key :inviter_ids, Array, :typecast => 'ObjectId'
|
||||
key :friend_ids, Array, :typecast => 'ObjectId'
|
||||
key :pending_request_ids, Array, :typecast => 'ObjectId'
|
||||
key :visible_post_ids, Array, :typecast => 'ObjectId'
|
||||
key :visible_person_ids, Array, :typecast => 'ObjectId'
|
||||
|
||||
key :invite_messages, Hash
|
||||
|
||||
|
|
|
|||
|
|
@ -55,8 +55,9 @@
|
|||
.avatar
|
||||
= owner_image_tag
|
||||
= link_to current_user.real_name, '#'
|
||||
%li= link_to "profile", current_user.person
|
||||
%li= link_to "settings", edit_user_path(current_user)
|
||||
%li= link_to "view profile", current_user.person
|
||||
%li= link_to "edit profile", edit_person_path(current_user.person)
|
||||
%li= link_to "account settings", edit_user_path(current_user)
|
||||
%li= link_to t('.logout.'), destroy_user_session_path
|
||||
|
||||
= render "shared/aspect_nav"
|
||||
|
|
|
|||
64
app/views/people/edit.html.haml
Normal file
64
app/views/people/edit.html.haml
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
|
||||
#section_header
|
||||
%h2
|
||||
Settings
|
||||
%ul#settings_nav
|
||||
%li=link_to 'Profile', edit_person_path(current_user.person)
|
||||
%li=link_to 'Account', edit_user_path(current_user)
|
||||
%li=link_to 'Services', services_path
|
||||
|
||||
.span-19.prepend-5.last
|
||||
= form_for @person do |person|
|
||||
%h3
|
||||
Your Profile
|
||||
.description
|
||||
This info will be available to whomever you connect with on Diaspora.
|
||||
|
||||
= person.error_messages
|
||||
|
||||
= person.fields_for :profile do |profile|
|
||||
%h4
|
||||
Your name
|
||||
= profile.text_field :first_name, :value => @profile.first_name, :placeholder => "First name"
|
||||
= profile.text_field :last_name, :value => @profile.last_name, :placeholder => "Last name"
|
||||
|
||||
%h4
|
||||
Your birthday
|
||||
%br
|
||||
= select_date Time.now, :order => [:month, :day, :year]
|
||||
|
||||
%h4
|
||||
Your bio
|
||||
= profile.text_area :bio, :value => @profile.bio, :rows => 5, :placeholder => "Fill me out"
|
||||
|
||||
%h4
|
||||
Your photo
|
||||
%div#image_picker
|
||||
= profile.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field'
|
||||
|
||||
- unless @photos.nil? || @photos.empty?
|
||||
- for photo in @photos
|
||||
- if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium))
|
||||
%div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'}
|
||||
= check_box_tag 'checked_photo', true, true
|
||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||
- else
|
||||
%div.small_photo{:id => photo.url(:thumb_medium)}
|
||||
= check_box_tag 'checked_photo'
|
||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||
|
||||
- else
|
||||
=t('.you_dont_have_any_photos')
|
||||
= link_to t('.albums'), albums_path(:aspect => 'all')
|
||||
=t('.page_to_upload_some')
|
||||
|
||||
=will_paginate @photos
|
||||
|
||||
.submit_block
|
||||
= link_to t('.cancel'), edit_user_path(current_user)
|
||||
= t('.or')
|
||||
= person.submit t('.update_profile')
|
||||
|
|
@ -6,8 +6,8 @@
|
|||
%h2
|
||||
Settings
|
||||
%ul#settings_nav
|
||||
%li=link_to 'Profile', '#', :class => 'profile'
|
||||
%li=link_to 'Account', '#', :class => 'account'
|
||||
%li=link_to 'Profile', edit_person_path(current_user.person)
|
||||
%li=link_to 'Account', edit_user_path(current_user)
|
||||
%li=link_to 'Services', services_path
|
||||
|
||||
.span-19.prepend-5.last
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
|
||||
%h3
|
||||
Your Account
|
||||
.description
|
||||
Connect Diaspora to publish to other applications, export your data, or close your account.
|
||||
|
||||
= form_for @user do |user|
|
||||
%h4
|
||||
Change Password
|
||||
= user.error_messages
|
||||
|
||||
= user.password_field :password, :placeholder => "New password"
|
||||
= user.password_field :password_confirmation, :placeholder => "Password confirmation"
|
||||
|
||||
.submit_block
|
||||
= link_to "Cancel", edit_user_path(current_user)
|
||||
or
|
||||
= user.submit 'Change password'
|
||||
|
||||
%h4
|
||||
Export Data
|
||||
%br
|
||||
%br
|
||||
= link_to "Download my account", users_export_path, :class => "button"
|
||||
= link_to "Download my photos", users_export_photos_path, :class => "button"
|
||||
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
%h4
|
||||
Close Account
|
||||
.description
|
||||
Closing your account will delete all of your posts, friends, and settings. You will be removed from this server.
|
||||
%br
|
||||
= link_to "Close Account", current_user,
|
||||
:confirm => "Are you sure?", :method => :delete,
|
||||
:class => "button"
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
|
||||
= form_for @user do |user|
|
||||
%h3
|
||||
Your Profile
|
||||
.description
|
||||
This info will be available to whomever you connect with on Diaspora.
|
||||
|
||||
= user.error_messages
|
||||
|
||||
= user.fields_for :profile do |profile|
|
||||
%h4
|
||||
Your name
|
||||
= profile.text_field :first_name, :value => @profile.first_name, :placeholder => "First name"
|
||||
= profile.text_field :last_name, :value => @profile.last_name, :placeholder => "Last name"
|
||||
|
||||
%h4
|
||||
Your birthday
|
||||
%br
|
||||
= select_date Time.now, :order => [:month, :day, :year]
|
||||
|
||||
%h4
|
||||
Your bio
|
||||
= profile.text_area :bio, :value => @profile.bio, :rows => 5, :placeholder => "Fill me out"
|
||||
|
||||
%h4
|
||||
Your photo
|
||||
%div#image_picker
|
||||
= profile.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field'
|
||||
|
||||
- unless @photos.nil? || @photos.empty?
|
||||
- for photo in @photos
|
||||
- if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium))
|
||||
%div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'}
|
||||
= check_box_tag 'checked_photo', true, true
|
||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||
- else
|
||||
%div.small_photo{:id => photo.url(:thumb_medium)}
|
||||
= check_box_tag 'checked_photo'
|
||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||
|
||||
- else
|
||||
=t('.you_dont_have_any_photos')
|
||||
= link_to t('.albums'), albums_path(:aspect => 'all')
|
||||
=t('.page_to_upload_some')
|
||||
|
||||
=will_paginate @photos
|
||||
|
||||
.submit_block
|
||||
= link_to t('.cancel'), edit_user_path(current_user)
|
||||
= t('.or')
|
||||
= user.submit t('.update_profile')
|
||||
|
|
@ -16,14 +16,44 @@
|
|||
%h2
|
||||
Settings
|
||||
%ul#settings_nav
|
||||
%li=link_to 'Profile', '#', :class => 'profile'
|
||||
%li=link_to 'Account', '#', :class => 'account'
|
||||
%li=link_to 'Profile', edit_person_path(current_user.person)
|
||||
%li=link_to 'Account', edit_user_path(current_user)
|
||||
%li=link_to 'Services', services_path
|
||||
|
||||
.span-19.prepend-5.last
|
||||
#profile.settings_pane{:style=>"display:block;"}
|
||||
= render 'users/profile'
|
||||
%h2 Account
|
||||
|
||||
#account.settings_pane
|
||||
= render 'users/account'
|
||||
= link_to "invite friends", new_user_invitation_path(current_user)
|
||||
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
%h3 Change Password
|
||||
= form_for @user do |f|
|
||||
= f.error_messages
|
||||
|
||||
%p
|
||||
= f.label :password, "New Password"
|
||||
= f.password_field :password
|
||||
%p
|
||||
= f.label :password_confirmation
|
||||
= f.password_field :password_confirmation
|
||||
|
||||
.submit_block
|
||||
= link_to "Cancel", edit_user_path(current_user)
|
||||
or
|
||||
= f.submit 'Change password'
|
||||
|
||||
%h3 Export Data
|
||||
= link_to "download my xml", users_export_path, :class => "button"
|
||||
= link_to "download my photos", users_export_photos_path, :class => "button"
|
||||
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
%h3 Close Account
|
||||
= link_to "Close Account", current_user,
|
||||
:confirm => "Are you sure?", :method => :delete,
|
||||
:class => "button"
|
||||
|
|
|
|||
|
|
@ -19,15 +19,15 @@
|
|||
|
||||
.span-15.last
|
||||
.floating
|
||||
= form_for @user do |user|
|
||||
= form_for @person do |person|
|
||||
%h3
|
||||
Your Profile
|
||||
.description
|
||||
This info will be available to whomever you connect with on Diaspora.
|
||||
|
||||
= user.error_messages
|
||||
= person.error_messages
|
||||
|
||||
= user.fields_for :profile do |profile|
|
||||
= person.fields_for :profile do |profile|
|
||||
%h4
|
||||
Your name
|
||||
= profile.text_field :first_name, :value => @profile.first_name, :placeholder => "First name"
|
||||
|
|
@ -69,5 +69,5 @@
|
|||
|
||||
|
||||
.submit_block
|
||||
= user.submit "Save and continue →"
|
||||
= person.submit "Save and continue →"
|
||||
|
||||
|
|
|
|||
|
|
@ -116,18 +116,6 @@ en:
|
|||
users:
|
||||
edit:
|
||||
editing_profile: "Editing profile"
|
||||
profile:
|
||||
cancel: "Cancel"
|
||||
update_profile: "Update Profile"
|
||||
home: "Home"
|
||||
diaspora_username: "DIASPORA USERNAME"
|
||||
info: "Info"
|
||||
picture: "Picture"
|
||||
editing_profile: "Editing profile"
|
||||
albums: "Albums"
|
||||
you_dont_have_any_photos: "You don't have any photos! Go to the"
|
||||
page_to_upload_some: "page to upload some."
|
||||
or: "or"
|
||||
destroy: "Account successfully closed."
|
||||
comments:
|
||||
comment:
|
||||
|
|
@ -218,6 +206,18 @@ en:
|
|||
are_you_sure: "Are you sure?"
|
||||
remove_friend: "remove friend"
|
||||
no_posts: "no posts to display!"
|
||||
edit:
|
||||
cancel: "Cancel"
|
||||
update_profile: "Update Profile"
|
||||
home: "Home"
|
||||
diaspora_username: "DIASPORA USERNAME"
|
||||
info: "Info"
|
||||
picture: "Picture"
|
||||
editing_profile: "Editing profile"
|
||||
albums: "Albums"
|
||||
you_dont_have_any_photos: "You don't have any photos! Go to the"
|
||||
page_to_upload_some: "page to upload some."
|
||||
or: "or"
|
||||
requests:
|
||||
new_request:
|
||||
add_a_new_friend_to: "Add a new friend to"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
Diaspora::Application.routes.draw do
|
||||
resources :people, :only => [:index, :show, :destroy]
|
||||
resources :people
|
||||
resources :status_messages, :only => [:create, :destroy, :show]
|
||||
resources :comments, :except => [:index]
|
||||
resources :requests, :except => [:edit, :update]
|
||||
|
|
|
|||
|
|
@ -29,9 +29,8 @@ module Diaspora
|
|||
end
|
||||
|
||||
def accept_friend_request(friend_request_id, aspect_id)
|
||||
request = Request.find_by_id(friend_request_id)
|
||||
pending_requests.delete(request)
|
||||
|
||||
request = pending_requests.find!(friend_request_id)
|
||||
pending_request_ids.delete(request.id.to_id)
|
||||
activate_friend(request.person, aspect_by_id(aspect_id))
|
||||
|
||||
request.reverse_for(self)
|
||||
|
|
@ -45,16 +44,16 @@ module Diaspora
|
|||
end
|
||||
|
||||
def accept_and_respond(friend_request_id, aspect_id)
|
||||
requester = Request.find_by_id(friend_request_id).person
|
||||
requester = pending_requests.find!(friend_request_id).person
|
||||
reversed_request = accept_friend_request(friend_request_id, aspect_id)
|
||||
dispatch_friend_acceptance reversed_request, requester
|
||||
end
|
||||
|
||||
def ignore_friend_request(friend_request_id)
|
||||
request = Request.find_by_id(friend_request_id)
|
||||
request = pending_requests.find!(friend_request_id)
|
||||
person = request.person
|
||||
|
||||
self.pending_requests.delete(request)
|
||||
self.pending_request_ids.delete(request.id)
|
||||
self.save
|
||||
|
||||
person.save
|
||||
|
|
|
|||
|
|
@ -853,6 +853,9 @@ h1.big_text
|
|||
:padding 4px 10px
|
||||
:color #CCC
|
||||
|
||||
:background
|
||||
:color #222
|
||||
|
||||
&:hover
|
||||
:background
|
||||
:color #000
|
||||
|
|
|
|||
|
|
@ -6,22 +6,22 @@ require 'spec_helper'
|
|||
|
||||
describe PeopleController do
|
||||
render_views
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
|
||||
sign_in :user, @user
|
||||
@user.aspect(:name => "lame-os")
|
||||
let(:user) { Factory(:user) }
|
||||
let!(:aspect) { user.aspect(:name => "lame-os") }
|
||||
|
||||
before do
|
||||
sign_in :user, user
|
||||
end
|
||||
|
||||
it "index should yield search results for substring of person name" do
|
||||
|
||||
eugene = Factory.create(:person, :profile => {:first_name => "Eugene", :last_name => "w"})
|
||||
get :index, :q => "Eu"
|
||||
assigns[:people].should include eugene
|
||||
end
|
||||
|
||||
it 'should go to the current_user show page' do
|
||||
get :show, :id => @user.person.id
|
||||
get :show, :id => user.person.id
|
||||
end
|
||||
|
||||
it "doesn't error out on an invalid id" do
|
||||
|
|
@ -29,6 +29,25 @@ describe PeopleController do
|
|||
end
|
||||
|
||||
it "doesn't error out on a nonexistent person" do
|
||||
get :show, :id => @user.id
|
||||
get :show, :id => user.id
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
context 'with a profile photo set' do
|
||||
it "doesn't overwrite the profile photo when an empty string is passed in" do
|
||||
user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg"
|
||||
user.person.profile.save
|
||||
|
||||
params = {"profile"=>
|
||||
{"image_url" => "",
|
||||
"last_name" => user.person.profile.last_name,
|
||||
"first_name" => user.person.profile.first_name}}
|
||||
|
||||
image_url = user.person.profile.image_url
|
||||
put("update", :id => user.person.id, "person" => params)
|
||||
|
||||
user.person.profile.image_url.should == image_url
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,10 +5,14 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe UsersController do
|
||||
|
||||
let(:user) { Factory(:user) }
|
||||
let!(:aspect) { user.aspect(:name => "lame-os") }
|
||||
|
||||
let!(:old_password) { user.encrypted_password }
|
||||
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
sign_in :user, @user
|
||||
@user.aspect(:name => "lame-os")
|
||||
sign_in :user, user
|
||||
end
|
||||
|
||||
describe '#export' do
|
||||
|
|
@ -18,67 +22,29 @@ describe UsersController do
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
describe '#update' do
|
||||
context 'with a profile photo set' do
|
||||
before do
|
||||
@user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg"
|
||||
@user.person.profile.save
|
||||
|
||||
@params = {"profile"=>
|
||||
{"image_url" => "",
|
||||
"last_name" => @user.person.profile.last_name,
|
||||
"first_name" => @user.person.profile.first_name}}
|
||||
end
|
||||
|
||||
it "doesn't overwrite the profile photo when an empty string is passed in" do
|
||||
image_url = @user.person.profile.image_url
|
||||
put("update", :id => @user.id, "user" => @params)
|
||||
|
||||
@user.person.profile.image_url.should == image_url
|
||||
end
|
||||
it "doesn't overwrite random attributes" do
|
||||
new_user = Factory.create(:user)
|
||||
@params[:owner_id] = new_user.id
|
||||
person = @user.person
|
||||
put('update', :id => @user.id, "user" => @params)
|
||||
Person.find(person.id).owner_id.should == @user.id
|
||||
end
|
||||
params = {:diaspora_handle => "notreal@stuff.com"}
|
||||
proc{ put 'update', :id => user.id, "user" => params }.should_not change(user, :diaspora_handle)
|
||||
end
|
||||
|
||||
context 'should allow the user to update their password' do
|
||||
it 'should change a users password ' do
|
||||
old_password = @user.encrypted_password
|
||||
|
||||
put("update", :id => @user.id, "user"=> {"password" => "foobaz", 'password_confirmation' => "foobaz","profile"=>
|
||||
{"image_url" => "",
|
||||
"last_name" => @user.person.profile.last_name,
|
||||
"first_name" => @user.person.profile.first_name}})
|
||||
|
||||
@user.reload
|
||||
@user.encrypted_password.should_not == old_password
|
||||
put("update", :id => user.id, "user"=> {"password" => "foobaz", 'password_confirmation' => "foobaz"})
|
||||
user.reload
|
||||
user.encrypted_password.should_not == old_password
|
||||
end
|
||||
|
||||
it 'should not change a password if they do not match' do
|
||||
old_password = @user.encrypted_password
|
||||
put("update", :id => @user.id, "user"=> {"password" => "foobarz", 'password_confirmation' => "not_the_same","profile"=>
|
||||
{"image_url" => "",
|
||||
"last_name" => @user.person.profile.last_name,
|
||||
"first_name" => @user.person.profile.first_name}})
|
||||
@user.reload
|
||||
@user.encrypted_password.should == old_password
|
||||
put("update", :id => user.id, "user"=> {"password" => "foobarz", 'password_confirmation' => "not_the_same"})
|
||||
user.reload
|
||||
user.encrypted_password.should == old_password
|
||||
end
|
||||
|
||||
|
||||
it 'should not update if the password fields are left blank' do
|
||||
|
||||
old_password = @user.encrypted_password
|
||||
put("update", :id => @user.id, "user"=> {"password" => "", 'password_confirmation' => "","profile"=>
|
||||
{"image_url" => "",
|
||||
"last_name" => @user.person.profile.last_name,
|
||||
"first_name" => @user.person.profile.first_name}})
|
||||
@user.reload
|
||||
@user.encrypted_password.should == old_password
|
||||
put("update", :id => user.id, "user"=> {"password" => "", 'password_confirmation' => ""})
|
||||
user.reload
|
||||
user.encrypted_password.should == old_password
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -31,17 +31,6 @@ describe Request do
|
|||
xml.should include user.exported_key
|
||||
end
|
||||
|
||||
it 'should allow me to see only friend requests sent to me' do
|
||||
remote_person = Factory.build(:person, :diaspora_handle => "robert@grimm.com", :url => "http://king.com/")
|
||||
|
||||
Request.instantiate(:into => aspect.id, :from => user.person, :to => remote_person.receive_url).save
|
||||
Request.instantiate(:into => aspect.id, :from => user.person, :to => remote_person.receive_url).save
|
||||
Request.instantiate(:into => aspect.id, :from => user.person, :to => remote_person.receive_url).save
|
||||
Request.instantiate(:into => aspect.id, :from => remote_person, :to => user.receive_url).save
|
||||
|
||||
Request.for_user(user).all.count.should == 1
|
||||
end
|
||||
|
||||
it 'should strip the destination url' do
|
||||
person_request = Request.new
|
||||
person_request.destination_url = " http://google.com/ "
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ describe Diaspora::UserModules::Friending do
|
|||
end
|
||||
|
||||
context 'friend requesting' do
|
||||
it "should assign a request to a aspect" do
|
||||
it "should assign a request to a aspect for the user that sent it out" do
|
||||
aspect.requests.size.should == 0
|
||||
|
||||
user.send_friend_request_to(friend, aspect)
|
||||
|
|
@ -34,21 +34,42 @@ describe Diaspora::UserModules::Friending do
|
|||
aspect.requests.size.should == 1
|
||||
end
|
||||
|
||||
it "should be able to accept a pending friend request" do
|
||||
describe '#receive_friend_request' do
|
||||
it 'adds a request to pending if it was not sent by user' do
|
||||
r = Request.instantiate(:to => user.receive_url, :from => friend)
|
||||
r.save
|
||||
user.receive_friend_request(r)
|
||||
user.reload.pending_requests.should include r
|
||||
end
|
||||
|
||||
proc { user.accept_friend_request(r.id, aspect.id) }.should change {
|
||||
Request.for_user(user).all.count }.by(-1)
|
||||
it 'should autoaccept a request the user sent' do
|
||||
request = user.send_friend_request_to(user2.person, aspect)
|
||||
request.reverse_for(user2)
|
||||
proc{user.receive_friend_request(request)}.should change(user.reload.friends, :count).by(1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'received a friend request' do
|
||||
|
||||
let(:request_for_user) {Request.instantiate(:to => user.receive_url, :from => friend)}
|
||||
let(:request2_for_user) {Request.instantiate(:to => user.receive_url, :from => person_one)}
|
||||
before do
|
||||
request_for_user.save
|
||||
user.receive_friend_request(request_for_user)
|
||||
user.receive_friend_request(request2_for_user)
|
||||
user.reload
|
||||
end
|
||||
|
||||
it "should delete an accepted friend request" do
|
||||
proc { user.accept_friend_request(request2_for_user.id, aspect.id) }.should change(
|
||||
user.reload.pending_requests, :count ).by(-1)
|
||||
end
|
||||
|
||||
it 'should be able to ignore a pending friend request' do
|
||||
friend = Factory.create(:person)
|
||||
r = Request.instantiate(:to => user.receive_url, :from => friend)
|
||||
r.save
|
||||
|
||||
proc { user.ignore_friend_request(r.id) }.should change {
|
||||
Request.for_user(user).count }.by(-1)
|
||||
proc { user.ignore_friend_request(request_for_user.id) }.should change (
|
||||
user.reload.pending_requests, :count ).by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not be able to friend request an existing friend' do
|
||||
|
|
@ -168,20 +189,20 @@ describe Diaspora::UserModules::Friending do
|
|||
user.receive_friend_request @request
|
||||
|
||||
person_two.destroy
|
||||
user.pending_requests.size.should be 1
|
||||
user.reload.pending_requests.size.should be 1
|
||||
user.friends.size.should be 0
|
||||
|
||||
user.receive_friend_request @request_two
|
||||
user.pending_requests.size.should be 2
|
||||
user.reload.pending_requests.size.should be 2
|
||||
user.friends.size.should be 0
|
||||
|
||||
user.accept_friend_request @request.id, aspect.id
|
||||
user.pending_requests.size.should be 1
|
||||
user.reload.pending_requests.size.should be 1
|
||||
user.friends.size.should be 1
|
||||
user.friends.include?(person_one).should be true
|
||||
|
||||
user.ignore_friend_request @request_two.id
|
||||
user.pending_requests.size.should be 0
|
||||
user.reload.pending_requests.size.should be 0
|
||||
user.friends.size.should be 1
|
||||
user.friends.include?(person_two).should be false
|
||||
end
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ ImageUploader.enable_processing = false
|
|||
|
||||
def friend_users(user1, aspect1, user2, aspect2)
|
||||
request = user1.send_friend_request_to(user2.person, aspect1)
|
||||
user2.receive_friend_request(request)
|
||||
reversed_request = user2.accept_friend_request( request.id, aspect2.id)
|
||||
user1.reload
|
||||
user1.receive reversed_request.to_diaspora_xml, user2.person
|
||||
|
|
|
|||
Loading…
Reference in a new issue