Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Milan
diaspora
Commits
b2239895
Commit
b2239895
authored
Dec 15, 2010
by
Raphael
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send requests from the aspect list on the person show page
parent
80a9b97f
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
88 additions
and
54 deletions
+88
-54
app/controllers/aspects_controller.rb
app/controllers/aspects_controller.rb
+5
-1
app/helpers/aspects_helper.rb
app/helpers/aspects_helper.rb
+14
-2
app/models/person.rb
app/models/person.rb
+12
-6
app/views/people/_aspect_list.haml
app/views/people/_aspect_list.haml
+12
-4
app/views/people/_profile_sidebar.html.haml
app/views/people/_profile_sidebar.html.haml
+1
-1
app/views/people/show.html.haml
app/views/people/show.html.haml
+0
-17
config/locales/diaspora/en.yml
config/locales/diaspora/en.yml
+1
-3
features/connects_users.feature
features/connects_users.feature
+7
-2
features/step_definitions/custom_web_steps.rb
features/step_definitions/custom_web_steps.rb
+10
-0
spec/controllers/aspects_controller_spec.rb
spec/controllers/aspects_controller_spec.rb
+22
-9
spec/models/person_spec.rb
spec/models/person_spec.rb
+4
-9
No files found.
app/controllers/aspects_controller.rb
View file @
b2239895
...
...
@@ -112,7 +112,11 @@ class AspectsController < ApplicationController
@aspect
=
current_user
.
aspects
.
find
(
params
[
:aspect_id
])
@contact
=
current_user
.
contact_for
(
@person
)
current_user
.
add_contact_to_aspect
(
@contact
,
@aspect
)
if
@contact
current_user
.
add_contact_to_aspect
(
@contact
,
@aspect
)
else
current_user
.
send_contact_request_to
(
@person
,
@aspect
)
end
flash
.
now
[
:notice
]
=
I18n
.
t
'aspects.add_to_aspect.success'
respond_to
do
|
format
|
...
...
app/helpers/aspects_helper.rb
View file @
b2239895
...
...
@@ -16,11 +16,23 @@ module AspectsHelper
end
def
add_to_aspect_button
(
aspect_id
,
person_id
)
link_to
image_tag
(
'icons/monotone_plus_add_round.png'
),
{
:controller
=>
"aspects"
,
:action
=>
'add_to_aspect'
,
:aspect_id
=>
aspect_id
,
:person_id
=>
person_id
},
:remote
=>
true
,
:class
=>
'add button'
link_to
image_tag
(
'icons/monotone_plus_add_round.png'
),
{
:controller
=>
"aspects"
,
:action
=>
'add_to_aspect'
,
:aspect_id
=>
aspect_id
,
:person_id
=>
person_id
},
:remote
=>
true
,
:class
=>
'add button'
end
def
remove_from_aspect_button
(
aspect_id
,
person_id
)
link_to
image_tag
(
'icons/monotone_check_yes.png'
),
{
:controller
=>
"aspects"
,
:action
=>
'remove_from_aspect'
,
:aspect_id
=>
aspect_id
,
:person_id
=>
person_id
},
:remote
=>
true
,
:class
=>
'added button'
link_to
image_tag
(
'icons/monotone_check_yes.png'
),
{
:controller
=>
"aspects"
,
:action
=>
'remove_from_aspect'
,
:aspect_id
=>
aspect_id
,
:person_id
=>
person_id
},
:remote
=>
true
,
:class
=>
'added button'
end
def
aspect_membership_button
(
aspect_id
,
contact
,
person
)
...
...
app/models/person.rb
View file @
b2239895
...
...
@@ -25,9 +25,9 @@ class Person
one
:profile
,
:class_name
=>
'Profile'
validates_associated
:profile
delegate
:first_name
,
:last_name
,
:to
=>
:profile
before_save
:downcase_diaspora_handle
delegate
:last_name
,
:to
=>
:profile
before_save
:downcase_diaspora_handle
def
downcase_diaspora_handle
diaspora_handle
.
downcase!
end
...
...
@@ -35,7 +35,7 @@ class Person
belongs_to
:owner
,
:class_name
=>
'User'
timestamps!
before_destroy
:remove_all_traces
before_validation
:clean_url
validates_presence_of
:url
,
:profile
,
:serialized_public_key
...
...
@@ -63,7 +63,7 @@ class Person
|
Person
.
searchable
.
all
(
'diaspora_handle'
=>
/^
#{
q
}
/i
,
'limit'
=>
30
)
\
|
p
end
return
p
end
...
...
@@ -74,7 +74,13 @@ class Person
"
#{
profile
.
first_name
.
to_s
}
#{
profile
.
last_name
.
to_s
}
"
end
end
def
first_name
@first_name
||=
if
profile
.
first_name
.
nil?
||
profile
.
first_name
.
blank?
self
.
diaspora_handle
.
split
(
'@'
).
first
else
profile
.
first_name
.
to_s
end
end
def
owns?
(
post
)
self
.
id
==
post
.
person
.
id
end
...
...
app/views/people/_aspect_list.haml
View file @
b2239895
...
...
@@ -23,6 +23,13 @@
});
.aspects
-
if
!
contact
%h4
=
t
(
'people.show.not_connected'
,
:name
=>
person
.
first_name
)
-
elsif
contact
.
pending
%h4
=
t
(
'people.person.pending_request'
)
.badges
{
:class
=>
(
"hidden"
if
!
contact
)}
-
for
aspect
in
aspects_with_person
=
render
:partial
=>
'aspects/aspect_badge'
,
:locals
=>
{
:aspect
=>
aspect
}
...
...
@@ -30,17 +37,17 @@
=
link_to
"edit aspect membership"
,
"#"
,
:id
=>
"edit_contact_aspects"
.edit
{
:class
=>
(
"hidden"
if
contact
)}
.contact_list
.contact_list
#aspects_list
%ul
-
for
aspect
in
aspects_with_person
%li
%li
{
:data
=>
{
:guid
=>
aspect
.
id
}}
%span
.name
=
link_to
aspect
.
name
,
aspect
.right
=
aspect_membership_button
(
aspect
.
id
,
contact
,
person
)
-
for
aspect
in
aspects_without_person
%li
%li
{
:data
=>
{
:guid
=>
aspect
.
id
}}
%span
.name
=
link_to
aspect
.
name
,
aspect
.right
...
...
@@ -48,4 +55,5 @@
.right
=
link_to
"done editing"
,
"#"
,
:id
=>
"done_contact_aspects"
=
link_to
t
(
'people.profile_sidebar.remove_contact'
),
person
,
:confirm
=>
t
(
'are_you_sure'
),
:method
=>
:delete
-
if
contact
=
link_to
t
(
'people.profile_sidebar.remove_contact'
),
person
,
:confirm
=>
t
(
'are_you_sure'
),
:method
=>
:delete
app/views/people/_profile_sidebar.html.haml
View file @
b2239895
...
...
@@ -25,7 +25,7 @@
%hr
{
:style
=>
"width:300px;"
}
%ul
-
if
contact
-
unless
person
==
current_user
.
person
%li
=
render
:partial
=>
'people/aspect_list'
,
:locals
=>
{
:person
=>
person
,
...
...
app/views/people/show.html.haml
View file @
b2239895
...
...
@@ -31,23 +31,6 @@
=
link_to
t
(
'.return_to_aspects'
),
aspects_manage_path
=
t
(
'.to_accept_or_ignore'
)
-
else
.floating
%h3
=
t
(
'.not_connected'
,
:name
=>
@person
.
name
)
-
unless
@outgoing_request
%h3
.description
=
t
(
'.request_people'
)
=
render
:partial
=>
'requests/new_request_to_person'
,
:locals
=>
{
:aspects
=>
@aspects
,
:destination_handle
=>
@person
.
diaspora_handle
}
-
else
%h3
.description
=
t
(
'.already_requested'
,
:name
=>
@person
.
name
)
-
if
@posts
.
count
>
0
-
if
@post_type
==
:photos
%h4
...
...
config/locales/diaspora/en.yml
View file @
b2239895
...
...
@@ -334,10 +334,8 @@ en:
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!"
not_connected
:
"
You
are
not
connected
with
this
person
"
not_connected
:
"
You
are
not
sharing
with
%{name}
"
recent_posts
:
"
Recent
Posts"
recent_public_posts
:
"
Recent
Public
Posts"
edit
:
...
...
features/connects_users.feature
View file @
b2239895
...
...
@@ -8,9 +8,9 @@ Feature: sending and receiving requests
Scenario
:
initiating and accepting a contact request
When
I sign in as
"bob@bob.bob"
And
I am on
"alice@alice.alice"
's page
And
I press
"add contact
"
And I press
the first ".add.button" within "#aspects_list ul > li
:
first-child
"
And
I wait for the ajax to finish
Then
I should see
"sent!
"
Then I should see
a ".added.button" within "#aspects_list ul > li
:
first-child
"
Then
I go to the destroy user session page
When
I sign in as
"alice@alice.alice"
...
...
@@ -23,4 +23,9 @@ Feature: sending and receiving requests
When
I go to the home page
Then
I go to the aspects manage page
Then
I should see 1 contact in
"Besties"
Then
I go to the destroy user session page
When
I sign in as
"bob@bob.bob"
And
I am on the aspects manage page
Then
I should see 1 contact in
"Besties"
features/step_definitions/custom_web_steps.rb
View file @
b2239895
...
...
@@ -16,6 +16,16 @@ When /^(.*) in the aspect list$/ do |action|
end
end
When
/^I press the first "([^"]*)"(?: within "([^"]*)")?$/
do
|
link_selector
,
within_selector
|
with_scope
(
within_selector
)
do
find
(
:css
,
link_selector
).
click
end
end
Then
/^(?:|I )should see a "([^"]*)"(?: within "([^"]*)")?$/
do
|
selector
,
scope_selector
|
with_scope
(
scope_selector
)
do
page
.
has_css?
(
selector
).
should
be_true
end
end
Then
/^I should see "([^\"]*)" in the main content area$/
do
|
stuff
|
within
(
"#main_stream"
)
do
Then
"I should see
#{
stuff
}
"
...
...
spec/controllers/aspects_controller_spec.rb
View file @
b2239895
...
...
@@ -21,6 +21,7 @@ describe AspectsController do
@user
.
getting_started
=
false
@user
.
save
sign_in
:user
,
@user
@controller
.
stub
(
:current_user
).
and_return
(
@user
)
request
.
env
[
"HTTP_REFERER"
]
=
'http://'
+
request
.
host
end
...
...
@@ -231,25 +232,37 @@ describe AspectsController do
@person
=
Factory
(
:person
)
end
it
'calls send_contact_request_to'
do
@user
.
should_receive
(
:send_contact_request_to
).
with
(
@person
,
@aspect1
)
post
'add_to_aspect'
,
:format
=>
'js'
,
:person_id
=>
@person
.
id
,
:aspect_id
=>
@aspect1
.
id
end
it
'does not call add_contact_to_aspect'
do
@user
.
should_not_receive
(
:add_contact_to_aspect
)
post
'add_to_aspect'
,
:format
=>
'js'
,
:person_id
=>
@person
.
id
,
:aspect_id
=>
@aspect1
.
id
end
end
it
'adds the users to the aspect'
do
@aspect1
.
reload
@aspect1
.
contacts
.
include?
(
@contact
).
should
be_false
post
'add_to_aspect'
,
:format
=>
'js'
,
:person_id
=>
@user2
.
person
.
id
,
:aspect_id
=>
@aspect1
.
id
@user
.
should_receive
(
:add_contact_to_aspect
)
post
'add_to_aspect'
,
:format
=>
'js'
,
:person_id
=>
@user2
.
person
.
id
,
:aspect_id
=>
@aspect1
.
id
response
.
should
be_success
@aspect1
.
reload
@aspect1
.
contacts
.
include?
(
@contact
).
should
be_true
end
end
describe
"#remove_from_aspect"
do
it
'removes contacts from an aspect'
do
@user
.
add_contact_to_aspect
(
@contact
,
@aspect1
)
@aspect
.
reload
@aspect
.
contacts
.
include?
(
@contact
).
should
be
true
post
'remove_from_aspect'
,
:format
=>
'js'
,
:person_id
=>
@user2
.
person
.
id
,
:aspect_id
=>
@aspect
.
id
post
'remove_from_aspect'
,
:format
=>
'js'
,
:person_id
=>
@user2
.
person
.
id
,
:aspect_id
=>
@aspect
.
id
response
.
should
be_success
@aspect
.
reload
@aspect
.
contacts
.
include?
(
@contact
).
should
be
false
...
...
spec/models/person_spec.rb
View file @
b2239895
...
...
@@ -14,11 +14,6 @@ describe Person do
end
describe
"delegating"
do
it
"delegates first_name to the profile"
do
@person
.
first_name
.
should
==
@person
.
profile
.
first_name
@person
.
profile
.
update_attributes
(
:first_name
=>
"Jane"
)
@person
.
reload
.
first_name
.
should
==
"Jane"
end
it
"delegates last_name to the profile"
do
@person
.
last_name
.
should
==
@person
.
profile
.
last_name
@person
.
profile
.
update_attributes
(
:last_name
=>
"Heathers"
)
...
...
@@ -121,7 +116,7 @@ describe Person do
Factory
.
create
(
:comment
,
:person_id
=>
person
.
id
,
:diaspora_handle
=>
person
.
diaspora_handle
,
:text
=>
"i love you"
,
:post
=>
status_message
)
Factory
.
create
(
:comment
,
:person_id
=>
@person
.
id
,
:diaspora_handle
=>
@person
.
diaspora_handle
,
:text
=>
"you are creepy"
,
:post
=>
status_message
)
lambda
{
person
.
destroy
}.
should_not
change
(
Comment
,
:count
)
end
...
...
@@ -245,14 +240,14 @@ describe Person do
Person
.
by_account_identifier
(
"tom@tom.joindiaspora.com"
).
diaspora_handle
.
should
==
"tom@tom.joindiaspora.com"
end
it
'should only find people who are exact matches (2/2)'
do
it
'should only find people who are exact matches (2/2)'
do
person
=
Factory
(
:person
,
:diaspora_handle
=>
"tomtom@tom.joindiaspora.com"
)
person1
=
Factory
(
:person
,
:diaspora_handle
=>
"tom@tom.joindiaspora.comm"
)
f
=
Person
.
by_account_identifier
(
"tom@tom.joindiaspora.com"
)
f
=
Person
.
by_account_identifier
(
"tom@tom.joindiaspora.com"
)
f
.
should
be
nil
end
end
describe
'.local_by_account_identifier'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment