Skip to content
Extraits de code Groupes Projets
Valider aa4a6187 rédigé par Sarah Mei's avatar Sarah Mei
Parcourir les fichiers

you can click on photos in manage aspects to see profiles

parent f4f864a4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -61,7 +61,7 @@ class User
person.save if person
end
attr_accessible :getting_started, :password, :password_confirmation, :language,
attr_accessible :getting_started, :password, :password_confirmation, :language,
def strip_and_downcase_username
if username.present?
......@@ -81,6 +81,12 @@ class User
super
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 ########
key :email, String
......@@ -350,7 +356,7 @@ class User
self.person.save!
self.save!
invitations_to_me.each{|invitation| invitation.to_request!}
self.reload # Because to_request adds a request and saves elsewhere
self
end
......@@ -366,7 +372,7 @@ class User
def setup(opts)
self.username = opts[:username]
opts[:person] ||= {}
opts[:person][:profile] ||= Profile.new
......
......@@ -27,7 +27,7 @@
.x
X
.circle
= person_image_tag(request.from)
= person_image_link(request.from)
= render 'shared/invitations', :invites => @invites
......@@ -53,7 +53,7 @@
.x
X
.circle
= person_image_tag(contact.person)
= person_image_link(contact.person)
.draggable_info
=t('.drag_to_add')
......
......@@ -24,6 +24,14 @@
%li
%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
.floating
%h3
......
......@@ -292,6 +292,9 @@ en:
results_for: "search results for"
show:
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."
already_requested: "You have already sent a request to %{name}."
does_not_exist: "Person does not exist!"
......
......@@ -5,20 +5,28 @@ Feature: managing contact requests
And I have an aspect called "Family"
And I have one contact request
Scenario: seeing contact requests
Scenario: seeing contact request notifications
When I am on the home page
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
Scenario: accepting a contact request
When I am on the home page
And I follow "Home (1)"
Then I should see "1 new request!"
And I should see 0 contacts in "Family"
And I follow "1 new request!"
Then I should see 0 contacts in "Family"
When I am on the home page
Then I follow "1 new request!"
And I drag the contact request to the "Family" aspect
When I drag the contact request to the "Family" aspect
And I wait for the ajax to finish
Then I should see 1 contact in "Family"
......
......@@ -26,6 +26,10 @@ When /^I wait for the aspects page to load$/ do
wait_until { current_path == aspects_path }
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
wait_until { evaluate_script("$.active") == 0 }
end
......@@ -47,4 +47,8 @@ When /^I click "X" on the contact request$/ do
window.confirm = function() { return true; };
$(".person.request.ui-draggable .delete").hover().click();
JS
end
\ No newline at end of file
end
When /^I click on the contact request$/ do
find(".person.request.ui-draggable a").click
end
......@@ -9,6 +9,8 @@ module NavigationHelpers
send("#{$1.gsub(/\W+/, '_')}_path")
when /^my edit profile page$/
edit_person_path(@me.person)
when /^the requestor's profile page$/
person_path(@me.reload.pending_requests.first.from)
when /^"(\/.*)"/
$1
else
......
......@@ -14,6 +14,28 @@ describe User do
user.encryption_key.should_not be nil
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
it 'does not overwrite old users with factory' do
pending "Why do you want to set ids directly? MONGOMAPPERRRRR!!!"
......@@ -26,9 +48,9 @@ describe User do
:email => "ohai@example.com",
:password => "password",
:password_confirmation => "password",
:person =>
{:profile =>
{:first_name => "O",
:person =>
{:profile =>
{:first_name => "O",
:last_name => "Hai"}
}
}
......@@ -105,12 +127,12 @@ describe User do
user = Factory.build(:user, :username => "kittens;")
user.should_not be_valid
end
it "can be 32 characters long" do
user = Factory.build(:user, :username => "hexagoooooooooooooooooooooooooon")
user.should be_valid
end
it "cannot be 33 characters" do
user = Factory.build(:user, :username => "hexagooooooooooooooooooooooooooon")
user.should_not be_valid
......@@ -154,9 +176,9 @@ describe User do
:email => "ohai@example.com",
:password => "password",
:password_confirmation => "password",
:person =>
{:profile =>
{:first_name => "O",
:person =>
{:profile =>
{:first_name => "O",
:last_name => "Hai"}
}
}
......@@ -206,10 +228,10 @@ describe User do
:email => "ohai@example.com",
:password => "password",
:password_confirmation => "password",
:person =>
:person =>
{:_id => person.id,
:profile =>
{:first_name => "O",
:profile =>
{:first_name => "O",
:last_name => "Hai"}
}
}
......@@ -257,7 +279,7 @@ describe User do
it 'sends a notification to aspects' do
user.should_receive(:push_to_aspects).twice
photo = user.post(:photo, :user_file => uploaded_photo, :caption => "hello", :to => aspect.id)
user.update_post(photo, :caption => 'hellp')
end
end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter