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
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gigadoc 2
diaspora
Commits
8ebf9c4a
Unverified
Commit
8ebf9c4a
authored
Feb 06, 2017
by
Benjamin Neff
Committed by
Steffen van Bergerem
Feb 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move publisher methods to PublisherHelper and check public publisher flag
This makes the #newhere post public again.
parent
44f712a2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
17 deletions
+92
-17
app/helpers/aspect_global_helper.rb
app/helpers/aspect_global_helper.rb
+1
-13
app/helpers/publisher_helper.rb
app/helpers/publisher_helper.rb
+18
-0
app/views/aspects/_aspect_dropdown.html.haml
app/views/aspects/_aspect_dropdown.html.haml
+3
-3
app/views/publisher/_publisher.html.haml
app/views/publisher/_publisher.html.haml
+1
-1
spec/helpers/publisher_helper_spec.rb
spec/helpers/publisher_helper_spec.rb
+69
-0
No files found.
app/helpers/aspect_global_helper.rb
View file @
8ebf9c4a
...
...
@@ -11,7 +11,7 @@ module AspectGlobalHelper
options
end
def
publisher_aspects_for
(
stream
=
nil
)
def
publisher_aspects_for
(
stream
)
if
stream
aspects
=
stream
.
aspects
aspect
=
stream
.
aspect
...
...
@@ -25,16 +25,4 @@ module AspectGlobalHelper
end
{
selected_aspects:
aspects
,
aspect:
aspect
,
aspect_ids:
aspect_ids
}
end
def
public_selected?
(
selected_aspects
)
"public"
==
selected_aspects
.
try
(
:first
)
end
def
all_aspects_selected?
(
aspects
,
selected_aspects
)
!
aspects
.
empty?
&&
aspects
.
size
==
selected_aspects
.
size
&&
!
public_selected?
(
selected_aspects
)
end
def
aspect_selected?
(
aspect
,
aspects
,
selected_aspects
)
selected_aspects
.
include?
(
aspect
)
&&
!
all_aspects_selected?
(
aspects
,
selected_aspects
)
end
end
app/helpers/publisher_helper.rb
View file @
8ebf9c4a
...
...
@@ -24,4 +24,22 @@ module PublisherHelper
end
end
end
def
public_selected?
(
selected_aspects
)
"public"
==
selected_aspects
.
try
(
:first
)
||
publisher_boolean?
(
:public
)
end
def
all_aspects_selected?
(
selected_aspects
)
!
all_aspects
.
empty?
&&
all_aspects
.
size
==
selected_aspects
.
size
&&
!
public_selected?
(
selected_aspects
)
end
def
aspect_selected?
(
aspect
,
selected_aspects
)
selected_aspects
.
include?
(
aspect
)
&&
!
all_aspects_selected?
(
selected_aspects
)
&&
!
public_selected?
(
selected_aspects
)
end
private
def
publisher_boolean?
(
option
)
@stream
.
try
(
:publisher
).
try
(
option
)
==
true
end
end
app/views/aspects/_aspect_dropdown.html.haml
View file @
8ebf9c4a
...
...
@@ -15,7 +15,7 @@
-
else
%i
.entypo-lock.small
#visibility-icon
%span
.text
-
if
all_aspects_selected?
(
all_aspects
,
selected_aspects
)
-
if
all_aspects_selected?
(
selected_aspects
)
=
t
(
"all_aspects"
)
-
elsif
selected_aspects
.
size
==
1
=
selected_aspects
.
first
.
name
...
...
@@ -31,7 +31,7 @@
%span
.text
=
t
(
"public"
)
%li
.all_aspects.radio
{
"data-aspect_id"
=>
"all_aspects"
,
:class
=>
(
"selected"
if
all_aspects_selected?
(
all_aspects
,
selected_aspects
))}
:class
=>
(
"selected"
if
all_aspects_selected?
(
selected_aspects
))}
%a
%span
.status_indicator
%i
.glyphicon.glyphicon-ok
...
...
@@ -40,7 +40,7 @@
%li
.divider
-
all_aspects
.
each
do
|
aspect
|
%li
.aspect_selector
{
"data-aspect_id"
=>
aspect
.
id
,
:class
=>
(
"selected"
if
aspect_selected?
(
aspect
,
all_aspects
,
selected_aspects
))}
:class
=>
(
"selected"
if
aspect_selected?
(
aspect
,
selected_aspects
))}
%a
%span
.status_indicator
%i
.glyphicon.glyphicon-ok
...
...
app/views/publisher/_publisher.html.haml
View file @
8ebf9c4a
...
...
@@ -42,7 +42,7 @@
-
if
public_selected?
(
selected_aspects
)
=
hidden_field_tag
"aspect_ids[]"
,
"public"
-
elsif
all_aspects_selected?
(
all_aspects
,
selected_aspects
)
-
elsif
all_aspects_selected?
(
selected_aspects
)
=
hidden_field_tag
"aspect_ids[]"
,
"all_aspects"
-
else
-
for
aspect_id
in
aspect_ids
...
...
spec/helpers/publisher_helper_spec.rb
0 → 100644
View file @
8ebf9c4a
describe
PublisherHelper
,
type: :helper
do
describe
"#public_selected?"
do
it
"returns true when the selected_aspects contains 'public'"
do
expect
(
helper
.
public_selected?
([
"public"
])).
to
be_truthy
end
it
"returns true when the publisher is set to public"
do
@stream
=
double
(
publisher:
double
(
public:
true
))
expect
(
helper
.
public_selected?
(
alice
.
aspects
.
to_a
)).
to
be_truthy
end
it
"returns false when the selected_aspects does not contain 'public' and the publisher is not public"
do
@stream
=
double
(
publisher:
double
(
public:
false
))
expect
(
helper
.
public_selected?
(
alice
.
aspects
.
to_a
)).
to
be_falsey
end
it
"returns false when the selected_aspects does not contain 'public' and there is no stream"
do
expect
(
helper
.
public_selected?
(
alice
.
aspects
.
to_a
)).
to
be_falsey
end
end
describe
"#all_aspects_selected?"
do
it
"returns true when the selected_aspects are the same size as all_aspects from the user"
do
expect
(
helper
).
to
receive
(
:all_aspects
).
twice
.
and_return
(
alice
.
aspects
.
to_a
)
expect
(
helper
.
all_aspects_selected?
(
alice
.
aspects
.
to_a
)).
to
be_truthy
end
it
"returns false when not all aspects are selected"
do
alice
.
aspects
.
create
(
name:
"other"
)
expect
(
helper
).
to
receive
(
:all_aspects
).
twice
.
and_return
(
alice
.
aspects
.
to_a
)
expect
(
helper
.
all_aspects_selected?
([
alice
.
aspects
.
first
])).
to
be_falsey
end
it
"returns false when the user does not have aspects"
do
expect
(
helper
).
to
receive
(
:all_aspects
).
and_return
([])
expect
(
helper
.
all_aspects_selected?
(
alice
.
aspects
.
to_a
)).
to
be_falsey
end
it
"returns false when the publisher is set to public"
do
@stream
=
double
(
publisher:
double
(
public:
true
))
expect
(
helper
).
to
receive
(
:all_aspects
).
twice
.
and_return
(
alice
.
aspects
.
to_a
)
expect
(
helper
.
all_aspects_selected?
(
alice
.
aspects
.
to_a
)).
to
be_falsey
end
end
describe
"#aspect_selected?"
do
before
do
alice
.
aspects
.
create
(
name:
"other"
)
allow
(
helper
).
to
receive
(
:all_aspects
).
and_return
(
alice
.
aspects
.
to_a
)
end
it
"returns true when the selected_aspects contains the aspect"
do
expect
(
helper
.
aspect_selected?
(
alice
.
aspects
.
first
,
[
alice
.
aspects
.
first
])).
to
be_truthy
end
it
"returns false when the selected_aspects does not contain the aspect"
do
expect
(
helper
.
aspect_selected?
(
alice
.
aspects
.
first
,
[
alice
.
aspects
.
second
])).
to
be_falsey
end
it
"returns false when all aspects are selected"
do
expect
(
helper
.
aspect_selected?
(
alice
.
aspects
.
first
,
alice
.
aspects
.
to_a
)).
to
be_falsey
end
it
"returns false when the publisher is set to public"
do
@stream
=
double
(
publisher:
double
(
public:
true
))
expect
(
helper
.
aspect_selected?
(
alice
.
aspects
.
first
,
[
alice
.
aspects
.
first
])).
to
be_falsey
end
end
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