Skip to content
Extraits de code Groupes Projets
Valider 9a23c92f rédigé par augier's avatar augier
Parcourir les fichiers

Show author of NSFW post

parent 6ee38434
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
$(document).ready(function(){ $(document).ready(function(){
$('.shield a').click(function(){ $('.shield a').click(function(){
$(this).parents('.shield_wrapper').remove(); $(this).parents(".stream_element").removeClass("shield-active");
return false; return false;
}); });
var showLoader = function(link){ var showLoader = function(link){
......
...@@ -78,20 +78,28 @@ h3 { margin-top: 0; } ...@@ -78,20 +78,28 @@ h3 { margin-top: 0; }
.photo_attachments{ margin-top: 6px; } .photo_attachments{ margin-top: 6px; }
.timeago{ font-weight: normal; } .timeago{ font-weight: normal; }
} }
.shield{ .shield{
padding: 10px; padding: 10px;
font-size: larger; font-size: larger;
} }
.shield_wrapper{ .nsfw-shield{
height: 100%; height: 100%;
width: 100%; width: 100%;
background-color: LightGrey; background-color: LightGrey;
position: absolute; border-radius: 0;
border-radius: 5px;
z-index: 2; z-index: 2;
} }
.stream_element:not(.shield-active) .shield{
display: none;
}
.stream_element.shield-active .nsfw-hidden{
display: none;
}
.new_comment { .new_comment {
padding: 10px; padding: 10px;
} }
...@@ -459,7 +467,7 @@ h3 { margin-top: 0; } ...@@ -459,7 +467,7 @@ h3 { margin-top: 0; }
width: 20px; width: 20px;
padding: 0; padding: 0;
margin-left: 15px; margin-left: 15px;
&:last-child{ &:last-child{
margin-right: 5px; margin-right: 5px;
} }
...@@ -572,10 +580,10 @@ select { ...@@ -572,10 +580,10 @@ select {
.reshare_via { .reshare_via {
width: 100%; width: 100%;
position: absolute; position: absolute;
bottom: -7px; bottom: -10px;
text-align: center; text-align: center;
span { span {
padding: 2px 10px; padding: 0 10px;
font-weight: bold; font-weight: bold;
color: $text-grey; color: $text-grey;
background: { background: {
......
...@@ -4,17 +4,22 @@ ...@@ -4,17 +4,22 @@
.reshare .reshare
- if post - if post
= render 'shared/photo_area', :post => post .nsfw-hidden
= render "shared/photo_area", post: post
.content .content
= render 'shared/post_info', :post => post = render "shared/post_info", post: post
- unless post.is_a?(Reshare)
= render "shared/nsfw_shield", post: post
- if !post.activity_streams? - if !post.activity_streams?
= render 'status_messages/status_message', :post => post, :photos => post.photos .nsfw-hidden
= render "status_messages/status_message", post: post, photos: post.photos
- else - else
.content .content
= t('.deleted') = t(".deleted")
.reshare_via .reshare_via
%span %span
= t('.reshared_via') = t(".reshared_via")
- if post.respond_to?(:nsfw) && post.nsfw
.nsfw-shield
.shield
%strong #NSFW
|
= link_to t("javascripts.stream.show_nsfw_post"), "#", class: "toggle_nsfw_state"
...@@ -31,5 +31,5 @@ ...@@ -31,5 +31,5 @@
- else - else
= t('limited') = t('limited')
- if !post.is_a?(Reshare) and post.location - if !post.is_a?(Reshare) and post.location
.location .location.nsfw-hidden
= t("posts.show.location", location: post.location.address) = t("posts.show.location", location: post.location.address)
...@@ -2,26 +2,24 @@ ...@@ -2,26 +2,24 @@
-# licensed under the Affero General Public License version 3 or later. See -# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file. -# the COPYRIGHT file.
.stream_element{data: {guid: post.id}} .stream_element{data: {guid: post.id}, class: post.respond_to?(:nsfw) && post.nsfw ? "shield-active" : ""}
- if post.respond_to?(:nsfw) && post.nsfw
.shield_wrapper
.shield
%strong #NSFW
|
= link_to t("javascripts.stream.show_nsfw_post"), "#"
- if post.is_a?(Reshare) - if post.is_a?(Reshare)
= render "reshares/reshare", reshare: post, post: post.absolute_root = render "reshares/reshare", reshare: post, post: post.absolute_root
= render "shared/photo_area", post: post .nsfw-hidden
= render "shared/photo_area", post: post
.content .content
= render "shared/post_info", post: post = render "shared/post_info", post: post
- unless post.is_a?(Reshare)
= render "shared/nsfw_shield", post: post
.nsfw-hidden
- if post.is_a?(StatusMessage) - if post.is_a?(StatusMessage)
= render "status_messages/status_message", post: post, photos: post.photos = render "status_messages/status_message", post: post, photos: post.photos
.bottom_bar .bottom_bar.nsfw-hidden
.floater .floater
= mobile_reshare_icon(post) = mobile_reshare_icon(post)
= mobile_comment_icon(post) = mobile_comment_icon(post)
...@@ -31,4 +29,3 @@ ...@@ -31,4 +29,3 @@
- if defined?(expanded_info) && expanded_info - if defined?(expanded_info) && expanded_info
= render partial: "shared/post_stats", locals: {post: @post} = render partial: "shared/post_stats", locals: {post: @post}
@javascript @mobile
Feature: Not safe for work
Background:
Given a nsfw user with email "tommy@nsfw.example.com"
And a user with email "laura@office.example.com"
And a user with email "laura@office.example.com" is connected with "tommy@nsfw.example.com"
Scenario: Setting not safe for work
And I sign in as "tommy@nsfw.example.com"
When I go to the edit profile page
And I mark myself as not safe for work
And I submit the form
Then I should be on the edit profile page
And the "profile[nsfw]" checkbox should be checked
When I go to the edit profile page
And I mark myself as safe for work
And I submit the form
Then I should be on the edit profile page
And the "profile[nsfw]" checkbox should not be checked
Scenario: Toggling nsfw state
#Nsfw users posts are marked nsfw
And "tommy@nsfw.example.com" has a public post with text "I love 0bj3ction4bl3 c0nt3nt!" and a poll
And "tommy@nsfw.example.com" has a public post with text "I love 0bj3ction4bl3 c0nt3nt!" and a location
And "tommy@nsfw.example.com" has a public post with text "I love 0bj3ction4bl3 c0nt3nt!" and a picture
#toggling nsfw state
When I sign in as "laura@office.example.com"
Then I should not see "I love 0bj3ction4bl3 c0nt3nt!"
And I should not see "What do you think about 1 ninjas?"
And I should not see "Posted from:"
And I should not see any picture in my stream
When I toggle all nsfw posts
Then I should see "I love 0bj3ction4bl3 c0nt3nt!"
And I should see "What do you think about 1 ninjas?"
And I should see "Posted from:"
And I should see 1 pictures in my stream
Scenario: Resharing a nsfw post with poll
And "tommy@nsfw.example.com" has a public post with text "Sexy Senators Gone Wild!" and a poll
And I sign in as "laura@office.example.com"
And I toggle all nsfw posts
And I follow "Reshare"
And I confirm the alert
And I go to the home page
Then I should not see "Sexy Senators Gone Wild!"
And I should not see "What do you think about 1 ninjas?"
And I should have 2 nsfw posts
Scenario: Resharing a nsfw post with location
And "tommy@nsfw.example.com" has a public post with text "Sexy Senators Gone Wild!" and a location
And I sign in as "laura@office.example.com"
And I toggle all nsfw posts
And I follow "Reshare"
And I confirm the alert
And I go to the home page
Then I should not see "Sexy Senators Gone Wild!"
And I should not see "Posted from:"
And I should have 2 nsfw posts
Scenario: Resharing a nsfw post with picture
And "tommy@nsfw.example.com" has a public post with text "Sexy Senators Gone Wild!" and a picture
And I sign in as "laura@office.example.com"
And I toggle all nsfw posts
And I follow "Reshare"
And I confirm the alert
And I go to the home page
Then I should not see "Sexy Senators Gone Wild!"
And I should not see any picture in my stream
And I should have 2 nsfw posts
...@@ -18,6 +18,14 @@ Then /^I should not see any posts in my stream$/ do ...@@ -18,6 +18,14 @@ Then /^I should not see any posts in my stream$/ do
page.assert_selector(".stream_element", count: 0) page.assert_selector(".stream_element", count: 0)
end end
Then /^I should not see any picture in my stream$/ do
expect(page).to have_selector(".photo_area img", count: 0)
end
Then /^I should see (\d+) pictures in my stream$/ do |count|
expect(page).to have_selector(".photo_area img", count: count)
end
Then /^I should not be able to submit the publisher$/ do Then /^I should not be able to submit the publisher$/ do
expect(publisher_submittable?).to be false expect(publisher_submittable?).to be false
end end
...@@ -27,6 +35,24 @@ Given /^"([^"]*)" has a public post with text "([^"]*)"$/ do |email, text| ...@@ -27,6 +35,24 @@ Given /^"([^"]*)" has a public post with text "([^"]*)"$/ do |email, text|
user.post(:status_message, :text => text, :public => true, :to => user.aspect_ids) user.post(:status_message, :text => text, :public => true, :to => user.aspect_ids)
end end
Given /^"([^"]*)" has a public post with text "([^"]*)" and a poll$/ do |email, text|
user = User.find_by(email: email)
post = user.post(:status_message, text: text, public: true, to: user.aspect_ids)
FactoryGirl.create(:poll, status_message: post)
end
Given /^"([^"]*)" has a public post with text "([^"]*)" and a location$/ do |email, text|
user = User.find_by(email: email)
post = user.post(:status_message, text: text, public: true, to: user.aspect_ids)
FactoryGirl.create(:location, status_message: post)
end
Given /^"([^"]*)" has a public post with text "([^"]*)" and a picture/ do |email, text|
user = User.find_by(email: email)
post = user.post(:status_message, text: text, public: true, to: user.aspect_ids)
FactoryGirl.create(:photo, status_message: post)
end
Given /^there are (\d+) public posts from "([^"]*)"$/ do |n_posts, email| Given /^there are (\d+) public posts from "([^"]*)"$/ do |n_posts, email|
user = User.find_by_email(email) user = User.find_by_email(email)
(1..n_posts.to_i).each do |n| (1..n_posts.to_i).each do |n|
......
...@@ -14,6 +14,10 @@ When /^I toggle nsfw posts$/ do ...@@ -14,6 +14,10 @@ When /^I toggle nsfw posts$/ do
find(".toggle_nsfw_state", match: :first).click find(".toggle_nsfw_state", match: :first).click
end end
When /^I toggle all nsfw posts$/ do
all("a.toggle_nsfw_state").each &:click
end
Then /^I should have (\d+) nsfw posts$/ do |num_posts| Then /^I should have (\d+) nsfw posts$/ do |num_posts|
page.should have_css(".nsfw-shield", count: num_posts.to_i) page.should have_css(".nsfw-shield", count: num_posts.to_i)
end end
...@@ -29,7 +29,7 @@ describe PostsController, type: :request do ...@@ -29,7 +29,7 @@ describe PostsController, type: :request do
get "/posts/#{sm.id}", format: :mobile get "/posts/#{sm.id}", format: :mobile
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(response.body).to match(/div class='location'/) expect(response.body).to match(/'location nsfw-hidden'/)
expect(response.body).to match(/#{I18n.t("posts.show.location", location: sm.location.address)}/) expect(response.body).to match(/#{I18n.t("posts.show.location", location: sm.location.address)}/)
end end
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