you can click on photos in manage aspects to see profiles

This commit is contained in:
Sarah Mei 2010-11-24 22:09:14 -08:00
parent f4f864a4fb
commit aa4a61870c
9 changed files with 82 additions and 25 deletions

View file

@ -61,7 +61,7 @@ class User
person.save if person person.save if person
end end
attr_accessible :getting_started, :password, :password_confirmation, :language, attr_accessible :getting_started, :password, :password_confirmation, :language,
def strip_and_downcase_username def strip_and_downcase_username
if username.present? if username.present?
@ -81,6 +81,12 @@ class User
super super
end end
def has_incoming_request_from(person)
self.pending_requests.select do |req|
req.to_id == self.person.id
end.any? { |req| req.from_id == person.id }
end
######## Making things work ######## ######## Making things work ########
key :email, String key :email, String
@ -350,7 +356,7 @@ class User
self.person.save! self.person.save!
self.save! self.save!
invitations_to_me.each{|invitation| invitation.to_request!} invitations_to_me.each{|invitation| invitation.to_request!}
self.reload # Because to_request adds a request and saves elsewhere self.reload # Because to_request adds a request and saves elsewhere
self self
end end
@ -366,7 +372,7 @@ class User
def setup(opts) def setup(opts)
self.username = opts[:username] self.username = opts[:username]
opts[:person] ||= {} opts[:person] ||= {}
opts[:person][:profile] ||= Profile.new opts[:person][:profile] ||= Profile.new

View file

@ -27,7 +27,7 @@
.x .x
X X
.circle .circle
= person_image_tag(request.from) = person_image_link(request.from)
= render 'shared/invitations', :invites => @invites = render 'shared/invitations', :invites => @invites
@ -53,7 +53,7 @@
.x .x
X X
.circle .circle
= person_image_tag(contact.person) = person_image_link(contact.person)
.draggable_info .draggable_info
=t('.drag_to_add') =t('.drag_to_add')

View file

@ -24,6 +24,14 @@
%li %li
%h3= t('.no_posts') %h3= t('.no_posts')
- elsif current_user.has_incoming_request_from(@person)
.floating
%h3
= t('.incoming_request')
%h4
= link_to t('.return_to_aspects'), aspects_manage_path
= t('.to_accept_or_ignore')
- else - else
.floating .floating
%h3 %h3

View file

@ -292,6 +292,9 @@ en:
results_for: "search results for" results_for: "search results for"
show: show:
no_posts: "no posts to display!" no_posts: "no posts to display!"
incoming_request: "You have an incoming request from this person."
return_to_aspects: "Return to your aspects page"
to_accept_or_ignore: "to accept or ignore it."
request_people: "If you'd like, you can request to place him/her in one of your aspects." request_people: "If you'd like, you can request to place him/her in one of your aspects."
already_requested: "You have already sent a request to %{name}." already_requested: "You have already sent a request to %{name}."
does_not_exist: "Person does not exist!" does_not_exist: "Person does not exist!"

View file

@ -5,20 +5,28 @@ Feature: managing contact requests
And I have an aspect called "Family" And I have an aspect called "Family"
And I have one contact request And I have one contact request
Scenario: seeing contact requests Scenario: seeing contact request notifications
When I am on the home page When I am on the home page
Then I should see "Home (1)" in the header Then I should see "Home (1)" in the header
When I follow "Home (1)"
Then I should see "1 new request!"
@javascript
Scenario: viewing a request's profile
When I am on the aspects manage page
Then I should see 1 contact request
When I click on the contact request
And I wait for the request's profile page to load
Then I should be on the requestor's profile page
And I should see "You have an incoming request from this person"
@javascript @javascript
Scenario: accepting a contact request Scenario: accepting a contact request
When I am on the home page When I am on the home page
And I follow "Home (1)" And I follow "1 new request!"
Then I should see "1 new request!" Then I should see 0 contacts in "Family"
And I should see 0 contacts in "Family"
When I am on the home page When I drag the contact request to the "Family" aspect
Then I follow "1 new request!"
And I drag the contact request to the "Family" aspect
And I wait for the ajax to finish And I wait for the ajax to finish
Then I should see 1 contact in "Family" Then I should see 1 contact in "Family"

View file

@ -26,6 +26,10 @@ When /^I wait for the aspects page to load$/ do
wait_until { current_path == aspects_path } wait_until { current_path == aspects_path }
end end
When /^I wait for the request's profile page to load$/ do
wait_until { current_path == person_path(@me.reload.pending_requests.first.from) }
end
When /^I wait for the ajax to finish$/ do When /^I wait for the ajax to finish$/ do
wait_until { evaluate_script("$.active") == 0 } wait_until { evaluate_script("$.active") == 0 }
end end

View file

@ -47,4 +47,8 @@ When /^I click "X" on the contact request$/ do
window.confirm = function() { return true; }; window.confirm = function() { return true; };
$(".person.request.ui-draggable .delete").hover().click(); $(".person.request.ui-draggable .delete").hover().click();
JS JS
end end
When /^I click on the contact request$/ do
find(".person.request.ui-draggable a").click
end

View file

@ -9,6 +9,8 @@ module NavigationHelpers
send("#{$1.gsub(/\W+/, '_')}_path") send("#{$1.gsub(/\W+/, '_')}_path")
when /^my edit profile page$/ when /^my edit profile page$/
edit_person_path(@me.person) edit_person_path(@me.person)
when /^the requestor's profile page$/
person_path(@me.reload.pending_requests.first.from)
when /^"(\/.*)"/ when /^"(\/.*)"/
$1 $1
else else

View file

@ -14,6 +14,28 @@ describe User do
user.encryption_key.should_not be nil user.encryption_key.should_not be nil
end end
describe "#has_incoming_request_from" do
it "returns true if the user has an incoming request from the person" do
user2.send_contact_request_to(user.person, aspect2)
user.reload
user2.reload
user.has_incoming_request_from(user2.person).should be_true
end
it "returns false if the user does not have an incoming request from the person" do
user.has_incoming_request_from(user2.person).should be_false
end
it "returns false if the user has requested to be contacts with the person" do
user.send_contact_request_to(user2.person, aspect)
user.reload
user2.reload
user.has_incoming_request_from(user2.person).should be_false
end
end
describe 'overwriting people' do describe 'overwriting people' do
it 'does not overwrite old users with factory' do it 'does not overwrite old users with factory' do
pending "Why do you want to set ids directly? MONGOMAPPERRRRR!!!" pending "Why do you want to set ids directly? MONGOMAPPERRRRR!!!"
@ -26,9 +48,9 @@ describe User do
:email => "ohai@example.com", :email => "ohai@example.com",
:password => "password", :password => "password",
:password_confirmation => "password", :password_confirmation => "password",
:person => :person =>
{:profile => {:profile =>
{:first_name => "O", {:first_name => "O",
:last_name => "Hai"} :last_name => "Hai"}
} }
} }
@ -105,12 +127,12 @@ describe User do
user = Factory.build(:user, :username => "kittens;") user = Factory.build(:user, :username => "kittens;")
user.should_not be_valid user.should_not be_valid
end end
it "can be 32 characters long" do it "can be 32 characters long" do
user = Factory.build(:user, :username => "hexagoooooooooooooooooooooooooon") user = Factory.build(:user, :username => "hexagoooooooooooooooooooooooooon")
user.should be_valid user.should be_valid
end end
it "cannot be 33 characters" do it "cannot be 33 characters" do
user = Factory.build(:user, :username => "hexagooooooooooooooooooooooooooon") user = Factory.build(:user, :username => "hexagooooooooooooooooooooooooooon")
user.should_not be_valid user.should_not be_valid
@ -154,9 +176,9 @@ describe User do
:email => "ohai@example.com", :email => "ohai@example.com",
:password => "password", :password => "password",
:password_confirmation => "password", :password_confirmation => "password",
:person => :person =>
{:profile => {:profile =>
{:first_name => "O", {:first_name => "O",
:last_name => "Hai"} :last_name => "Hai"}
} }
} }
@ -206,10 +228,10 @@ describe User do
:email => "ohai@example.com", :email => "ohai@example.com",
:password => "password", :password => "password",
:password_confirmation => "password", :password_confirmation => "password",
:person => :person =>
{:_id => person.id, {:_id => person.id,
:profile => :profile =>
{:first_name => "O", {:first_name => "O",
:last_name => "Hai"} :last_name => "Hai"}
} }
} }
@ -257,7 +279,7 @@ describe User do
it 'sends a notification to aspects' do it 'sends a notification to aspects' do
user.should_receive(:push_to_aspects).twice user.should_receive(:push_to_aspects).twice
photo = user.post(:photo, :user_file => uploaded_photo, :caption => "hello", :to => aspect.id) photo = user.post(:photo, :user_file => uploaded_photo, :caption => "hello", :to => aspect.id)
user.update_post(photo, :caption => 'hellp') user.update_post(photo, :caption => 'hellp')
end end
end end