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
789ff679
Commit
789ff679
authored
Jan 31, 2011
by
zhitomirskiyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
persists open aspects across logins also fixed the status message controller spec broken in master
parent
a68bdd61
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
79 additions
and
12 deletions
+79
-12
app/controllers/aspects_controller.rb
app/controllers/aspects_controller.rb
+2
-0
app/controllers/home_controller.rb
app/controllers/home_controller.rb
+1
-1
app/models/user.rb
app/models/user.rb
+3
-0
db/migrate/20110201013408_add_open_aspects_to_user.rb
db/migrate/20110201013408_add_open_aspects_to_user.rb
+9
-0
db/schema.rb
db/schema.rb
+2
-3
features/saved_state.feature
features/saved_state.feature
+17
-6
features/step_definitions/user_steps.rb
features/step_definitions/user_steps.rb
+14
-0
spec/controllers/aspects_controller_spec.rb
spec/controllers/aspects_controller_spec.rb
+18
-0
spec/controllers/home_controller_spec.rb
spec/controllers/home_controller_spec.rb
+12
-1
spec/controllers/status_message_controller_spec.rb
spec/controllers/status_message_controller_spec.rb
+1
-1
No files found.
app/controllers/aspects_controller.rb
View file @
789ff679
...
...
@@ -15,6 +15,8 @@ class AspectsController < ApplicationController
else
@aspects
=
current_user
.
aspects
.
includes
(
:contacts
=>
{
:person
=>
:profile
})
end
current_user
.
open_aspects
=
params
[
:a_ids
]
current_user
.
save
# redirect to signup
if
current_user
.
getting_started
==
true
||
@aspects
.
blank?
...
...
app/controllers/home_controller.rb
View file @
789ff679
...
...
@@ -6,7 +6,7 @@ class HomeController < ApplicationController
def
show
if
current_user
redirect_to
aspects
_path
redirect_to
:controller
=>
'aspects'
,
:action
=>
'index'
,
:a_ids
=>
current_user
.
open_
aspects
elsif
is_mobile_device?
redirect_to
user_session_path
else
...
...
app/models/user.rb
View file @
789ff679
...
...
@@ -38,6 +38,9 @@ class User < ActiveRecord::Base
has_many
:contact_people
,
:through
=>
:contacts
has_many
:services
serialize
:open_aspects
,
Array
before_destroy
:disconnect_everyone
,
:remove_person
before_save
do
person
.
save
if
person
...
...
db/migrate/20110201013408_add_open_aspects_to_user.rb
0 → 100644
View file @
789ff679
class
AddOpenAspectsToUser
<
ActiveRecord
::
Migration
def
self
.
up
add_column
(
:users
,
:open_aspects
,
:text
)
end
def
self
.
down
remove_column
(
:users
,
:open_aspects
)
end
end
db/schema.rb
View file @
789ff679
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
20110
130072907
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
20110
201013408
)
do
create_table
"aspect_memberships"
,
:force
=>
true
do
|
t
|
t
.
integer
"aspect_id"
,
:null
=>
false
...
...
@@ -312,10 +312,8 @@ ActiveRecord::Schema.define(:version => 20110130072907) do
t
.
boolean
"unread"
,
:default
=>
true
,
:null
=>
false
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
string
"mongo_id"
end
add_index
"notifications"
,
[
"mongo_id"
],
:name
=>
"index_notifications_on_mongo_id"
add_index
"notifications"
,
[
"recipient_id"
],
:name
=>
"index_notifications_on_recipient_id"
add_index
"notifications"
,
[
"target_id"
],
:name
=>
"index_notifications_on_target_id"
add_index
"notifications"
,
[
"target_type"
,
"target_id"
],
:name
=>
"index_notifications_on_target_type_and_target_id"
...
...
@@ -460,6 +458,7 @@ ActiveRecord::Schema.define(:version => 20110130072907) do
t
.
string
"mongo_id"
t
.
string
"invitation_service"
t
.
string
"invitation_identifier"
t
.
text
"open_aspects"
end
add_index
"users"
,
[
"email"
],
:name
=>
"index_users_on_email"
...
...
features/saved_state.feature
View file @
789ff679
@javascript
Feature
:
saved state
Scenario
:
open aspects persist
Scenario
:
open aspects persist
across sessions
Given
I am signed in
And
I have an aspect called
"Open 1"
And
I have an aspect called
"Closed 1"
And
I have an aspect called
"Closed 2"
And
I have an aspect called
"Open 2"
And
I am on the aspects page
When
I follow
"Open 1"
And
I follow
"Open 2"
Then
I should have aspects
"Open 1"
,
"Open 2"
open
Then
I should have aspect
"Open 1"
"selected"
Then
I should have aspect
"Open 2"
"selected"
Then
I should have aspect
"Closed 1"
"not selected"
Then
I should have aspect
"Closed 2"
"not selected"
And
I click on my name in the header
And
I follow
"logout"
And
I go to the new user session page
And
I fill in
"Username"
with
"ohai"
And
I fill in
"Password"
with
"secret"
Then
I should be on the aspects page
Then
I should have aspects
"Open 1"
,
"Open 2"
open
And
I am signed in
Then
I should be on the aspects page
Then
I should have aspect
"Open 1"
"selected"
But
I should have aspect
"Open 2"
"selected"
But
I should have aspect
"Closed 1"
"not selected"
But
I should have aspect
"Closed 2"
"not selected"
features/step_definitions/user_steps.rb
View file @
789ff679
...
...
@@ -71,3 +71,17 @@ end
When
/^I click on the contact request$/
do
find
(
".person.request.ui-draggable a"
).
click
end
Then
/^I should have aspect "([^"]*)" "([^"]*)"$/
do
|
arg1
,
arg2
|
@aspect
=
Aspect
.
where
(
:name
=>
arg1
).
first
val
=
evaluate_script
(
"$('#aspect_nav').children('li[data-guid=
#{
@aspect
.
id
}
]').hasClass('selected');"
)
#
if
arg2
==
"selected"
val
.
should
==
true
elsif
arg2
==
"not selected"
val
.
should
==
false
else
raise
"Aspect state should either be 'selected' or 'not selected'"
end
end
spec/controllers/aspects_controller_spec.rb
View file @
789ff679
...
...
@@ -87,6 +87,23 @@ describe AspectsController do
get
:index
,
:a_ids
=>
[
@aspect0
.
id
.
to_s
,
@aspect1
.
id
.
to_s
]
assigns
(
:posts
).
length
.
should
==
8
end
context
"storing state"
do
before
do
@index_params
=
{
:a_ids
=>
[
@aspect0
.
id
.
to_s
,
@aspect1
.
id
.
to_s
]}
end
it
"stores the aspect params in the user"
do
get
:index
,
@index_params
@user
.
reload
.
open_aspects
.
should
==
@index_params
[
:a_ids
]
end
it
"correctly stores the aspect params"
do
@user
.
open_aspects
=
@index_params
[
:a_ids
]
@user
.
save
get
:index
@user
.
reload
.
open_aspects
.
should
==
nil
end
end
end
context
'performance'
do
...
...
@@ -319,6 +336,7 @@ describe AspectsController do
describe
"#hashes_for_posts"
do
it
'returns only distinct people'
do
pending
end
end
end
spec/controllers/home_controller_spec.rb
View file @
789ff679
...
...
@@ -23,7 +23,18 @@ describe HomeController do
it
'redirects to aspects index if user is logged in'
do
sign_in
@user
get
:show
response
.
should
redirect_to
aspects_path
response
.
should
redirect_to
(
:controller
=>
'aspects'
,
:action
=>
'index'
)
end
it
'redirects to aspects index with stored aspects'
do
sign_in
@user
@aspect0
=
@user
.
aspects
.
all
[
0
]
@aspect1
=
@user
.
aspects
.
create
(
:name
=>
"Yeaaaah!"
)
@index_params
=
{
:a_ids
=>
[
@aspect0
.
id
.
to_s
,
@aspect1
.
id
.
to_s
]}
@user
.
open_aspects
=
@index_params
[
:a_ids
]
@user
.
save
get
:show
response
.
should
redirect_to
(
:controller
=>
'aspects'
,
:action
=>
'index'
,
:a_ids
=>
@index_params
[
:a_ids
]
)
end
end
...
...
spec/controllers/status_message_controller_spec.rb
View file @
789ff679
...
...
@@ -30,7 +30,7 @@ describe StatusMessagesController do
end
it
'succeeds'
do
get
:show
,
"id"
=>
message
.
id
.
to_s
get
:show
,
"id"
=>
@
message
.
id
.
to_s
response
.
should
be_success
end
...
...
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