diff options
author | flaburgan <flaburgan@geexxx.fr> | 2018-10-29 00:52:59 +0300 |
---|---|---|
committer | Benjamin Neff <benjamin@coding4coffee.ch> | 2019-01-07 00:02:10 +0300 |
commit | 6804132c1571d5e03cbc5ad6529bafbd8d28b827 (patch) | |
tree | 912d20bd3312a2f09b4188be9a2f74de555e3321 | |
parent | 58d2ce7ba67ba4cc55b7dee6f1a4f3cad5a3b9bd (diff) |
Do not autofollow back a user you are ignoring
fixes #7808
closes #7913
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | app/models/user/connecting.rb | 2 | ||||
-rw-r--r-- | features/desktop/auto_follow_back.feature | 36 | ||||
-rw-r--r-- | features/step_definitions/aspects_steps.rb | 24 | ||||
-rw-r--r-- | features/step_definitions/user_steps.rb | 11 |
5 files changed, 63 insertions, 11 deletions
diff --git a/Changelog.md b/Changelog.md index 6dbf4de3c..1ec03fca1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,7 @@ * Improve public stream performance and cleanup unused indexes [#7944](https://github.com/diaspora/diaspora/pull/7944) ## Bug fixes +* Do not autofollow back a user you are ignoring [#7913](https://github.com/diaspora/diaspora/pull/7913) ## Features * Suppoert ignore users on mobile [#7884](https://github.com/diaspora/diaspora/pull/7884) diff --git a/app/models/user/connecting.rb b/app/models/user/connecting.rb index 4ddd46e3e..232dba405 100644 --- a/app/models/user/connecting.rb +++ b/app/models/user/connecting.rb @@ -11,6 +11,8 @@ class User # @param [Aspect] aspect The aspect to add them to. # @return [Contact] The newly made contact for the passed in person. def share_with(person, aspect) + return if blocks.where(person_id: person.id).exists? + contact = contacts.find_or_initialize_by(person_id: person.id) return false unless contact.valid? diff --git a/features/desktop/auto_follow_back.feature b/features/desktop/auto_follow_back.feature new file mode 100644 index 000000000..1b7404805 --- /dev/null +++ b/features/desktop/auto_follow_back.feature @@ -0,0 +1,36 @@ +@javascript +Feature: auto follow back a user + + Background: + Given following users exist: + | username | email | + | Bob Jones | bob@bob.bob | + | Alice Smith | alice@alice.alice | + And I sign in as "bob@bob.bob" + And I have an aspect called "My main aspect" + And I have an aspect called "Others" with auto follow back + And I sign out + + Scenario: When a user with auto follow back enabled is shared with, he's sharing back + When I sign in as "alice@alice.alice" + And I am on "bob@bob.bob"'s page + And I add the person to my "Besties" aspect + And I sign out + And I sign in as "bob@bob.bob" + Then I should have 1 contact in "Others" + When I am on "alice@alice.alice"'s page + Then I should see "Others" within the contact aspect dropdown + + Scenario: When a user with auto follow back enabled is shared with by a user he's ignoring, he's not sharing back + When I sign in as "bob@bob.bob" + And I am on "alice@alice.alice"'s page + And I click on the profile block button + And I sign out + When I sign in as "alice@alice.alice" + And I am on "bob@bob.bob"'s page + And I add the person to my "Besties" aspect + And I sign out + And I sign in as "bob@bob.bob" + Then I should have 0 contact in "Others" + When I am on "alice@alice.alice"'s page + Then I should see "Stop ignoring" within "#unblock_user_button" diff --git a/features/step_definitions/aspects_steps.rb b/features/step_definitions/aspects_steps.rb index 9add74766..b00ddf731 100644 --- a/features/step_definitions/aspects_steps.rb +++ b/features/step_definitions/aspects_steps.rb @@ -38,6 +38,26 @@ module AspectCukeHelpers end World(AspectCukeHelpers) +Given /^I have an aspect called "([^\"]*)"$/ do |aspect_name| + @me.aspects.create!(name: aspect_name) + @me.reload +end + +Given /^I have an aspect called "([^\"]*)" with auto follow back$/ do |aspect_name| + aspect = @me.aspects.create!(name: aspect_name) + @me.auto_follow_back = true + @me.auto_follow_back_aspect = aspect + @me.save + @me.reload +end + +Given /^I have following aspect[s]?:$/ do |fields| + fields.raw.each do |field| + @me.aspects.create!(name: field[0]) + end + @me.reload +end + When /^I click on "([^"]*)" aspect edit icon$/ do |aspect_name| within(".all-aspects") do li = find('li', text: aspect_name) @@ -112,6 +132,10 @@ And /^I toggle the aspect "([^"]*)"$/ do |name| toggle_aspect(name) end +Then /^I should see "([^"]*)" within the contact aspect dropdown$/ do |aspect_name| + expect(find(".dropdown-toggle .text")).to have_content aspect_name +end + Then /^I should see "([^"]*)" aspect selected$/ do |aspect_name| aspect = @me.aspects.where(:name => aspect_name).first within("#aspects_list") do diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index e50102961..ee4e71b69 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -72,17 +72,6 @@ When /^I click on my name$/ do click_link("#{@me.first_name} #{@me.last_name}") end -Given /^I have an aspect called "([^\"]*)"$/ do |aspect_name| - @me.aspects.create!(:name => aspect_name) - @me.reload -end - -Given /^I have following aspect[s]?:$/ do |fields| - fields.raw.each do |field| - step %{I have an aspect called "#{field[0]}"} - end -end - When /^I have user with username "([^"]*)" in an aspect called "([^"]*)"$/ do |username, aspect| user = User.find_by_username(username) contact = @me.reload.contact_for(user.person) |