Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
diaspora
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Milan
diaspora
Commits
b90dc790
Commit
b90dc790
authored
Apr 04, 2015
by
Jonne Haß
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5846 from svbergerem/fix-destroying-auto-follow-back-aspect
Disable auto follow back on aspect deletion
parents
55593bfb
019dc147
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
5 deletions
+80
-5
Changelog.md
Changelog.md
+9
-0
app/controllers/aspects_controller.rb
app/controllers/aspects_controller.rb
+9
-3
config/locales/diaspora/en.yml
config/locales/diaspora/en.yml
+2
-1
db/migrate/20150403192408_remove_deleted_aspects_from_auto_follow_back.rb
...403192408_remove_deleted_aspects_from_auto_follow_back.rb
+11
-0
db/schema.rb
db/schema.rb
+1
-1
spec/controllers/aspects_controller_spec.rb
spec/controllers/aspects_controller_spec.rb
+48
-0
No files found.
Changelog.md
View file @
b90dc790
# Head
## Refactor
## Bug fixes
*
Disable auto follow back on aspect deletion
[
#5846
](
https://github.com/diaspora/diaspora/pull/5846
)
## Features
# 0.5.0.0
## Major Sidekiq update
...
...
app/controllers/aspects_controller.rb
View file @
b90dc790
...
...
@@ -44,14 +44,20 @@ class AspectsController < ApplicationController
end
def
destroy
@aspect
=
current_user
.
aspects
.
where
(
:id
=>
params
[
:id
]).
first
@aspect
=
current_user
.
aspects
.
where
(
id:
params
[
:id
]).
first
begin
if
current_user
.
auto_follow_back
&&
@aspect
.
id
==
current_user
.
auto_follow_back_aspect
.
id
current_user
.
update
(
auto_follow_back:
false
,
auto_follow_back_aspect:
nil
)
flash
[
:notice
]
=
I18n
.
t
"aspects.destroy.success_auto_follow_back"
,
name:
@aspect
.
name
else
flash
[
:notice
]
=
I18n
.
t
"aspects.destroy.success"
,
name:
@aspect
.
name
end
@aspect
.
destroy
flash
[
:notice
]
=
I18n
.
t
'aspects.destroy.success'
,
:name
=>
@aspect
.
name
rescue
ActiveRecord
::
StatementInvalid
=>
e
flash
[
:error
]
=
I18n
.
t
'aspects.destroy.failure'
,
:name
=>
@aspect
.
name
flash
[
:error
]
=
I18n
.
t
"aspects.destroy.failure"
,
name:
@aspect
.
name
end
if
request
.
referer
.
include?
(
'contacts'
)
redirect_to
contacts_path
else
...
...
config/locales/diaspora/en.yml
View file @
b90dc790
...
...
@@ -215,7 +215,8 @@ en:
failure
:
"
Aspect
creation
failed."
destroy
:
success
:
"
%{name}
was
successfully
removed."
failure
:
"
%{name}
is
not
empty
and
could
not
be
removed."
success_auto_follow_back
:
"
%{name}
was
successfully
removed.
You
used
this
aspect
to
automatically
follow
back
users.
Check
your
user
settings
to
select
a
new
auto
follow
back
aspect."
failure
:
"
%{name}
could
not
be
removed."
update
:
success
:
"
Your
aspect,
%{name},
has
been
successfully
edited."
failure
:
"
Your
aspect,
%{name},
had
too
long
name
to
be
saved."
...
...
db/migrate/20150403192408_remove_deleted_aspects_from_auto_follow_back.rb
0 → 100644
View file @
b90dc790
class
RemoveDeletedAspectsFromAutoFollowBack
<
ActiveRecord
::
Migration
def
up
User
.
where
.
not
(
auto_follow_back_aspect_id:
Aspect
.
select
(
:id
))
.
where
(
auto_follow_back:
true
)
.
update_all
(
auto_follow_back:
false
,
auto_follow_back_aspect_id:
nil
)
end
def
down
raise
ActiveRecord
::
IrreversibleMigration
end
end
db/schema.rb
View file @
b90dc790
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20150
220001357
)
do
ActiveRecord
::
Schema
.
define
(
version:
20150
403192408
)
do
create_table
"account_deletions"
,
force: :cascade
do
|
t
|
t
.
string
"diaspora_handle"
,
limit:
255
...
...
spec/controllers/aspects_controller_spec.rb
View file @
b90dc790
...
...
@@ -112,6 +112,54 @@ describe AspectsController, :type => :controller do
end
end
describe
"#destroy"
do
before
do
@alices_aspect_1
=
alice
.
aspects
.
create
(
name:
"Contacts"
)
end
context
"with no auto follow back aspect"
do
it
"destoys the aspect"
do
expect
(
alice
.
aspects
.
to_a
).
to
include
@alices_aspect_1
post
:destroy
,
id:
@alices_aspect_1
.
id
expect
(
alice
.
reload
.
aspects
.
to_a
).
not_to
include
@alices_aspect_1
end
it
"renders a flash message on success"
do
post
:destroy
,
id:
@alices_aspect_1
.
id
expect
(
flash
[
:notice
]).
to
eq
(
I18n
.
t
(
"aspects.destroy.success"
,
name:
@alices_aspect_1
.
name
))
expect
(
flash
[
:error
]).
to
be_blank
end
end
context
"with the aspect set as auto follow back"
do
before
do
alice
.
auto_follow_back
=
true
alice
.
auto_follow_back_aspect
=
@alices_aspect_1
alice
.
save
end
it
"destoys the aspect"
do
expect
(
alice
.
aspects
.
to_a
).
to
include
@alices_aspect_1
post
:destroy
,
id:
@alices_aspect_1
.
id
expect
(
alice
.
reload
.
aspects
.
to_a
).
not_to
include
@alices_aspect_1
end
it
"disables auto follow back"
do
expect
(
alice
.
auto_follow_back
).
to
be
(
true
)
expect
(
alice
.
auto_follow_back_aspect
).
to
eq
(
@alices_aspect_1
)
post
:destroy
,
id:
@alices_aspect_1
.
id
expect
(
alice
.
auto_follow_back
).
to
be
(
false
)
expect
(
alice
.
auto_follow_back_aspect
).
to
eq
(
nil
)
end
it
"renders a flash message telling you to set a new auto follow back aspect"
do
post
:destroy
,
id:
@alices_aspect_1
.
id
expect
(
flash
[
:notice
]).
to
eq
(
I18n
.
t
(
"aspects.destroy.success_auto_follow_back"
,
name:
@alices_aspect_1
.
name
))
expect
(
flash
[
:error
]).
to
be_blank
end
end
end
describe
"#toggle_contact_visibility"
do
it
'sets contacts visible'
do
@alices_aspect_1
.
contacts_visible
=
false
...
...
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