From 3990bebcf4f837a9ace2b837c2735fd6ec6ce5bf Mon Sep 17 00:00:00 2001 From: movilla Date: Mon, 18 Mar 2013 14:32:12 +0100 Subject: [PATCH] Fix mobile view of deleted reshares --- Changelog.md | 1 + app/helpers/mobile_helper.rb | 8 ++-- features/reshare_mobile.feature | 45 +++++++++++++++++++ features/step_definitions/custom_web_steps.rb | 4 ++ 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 features/reshare_mobile.feature diff --git a/Changelog.md b/Changelog.md index 11e130de4..38d420ca1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ * Pass the real values to stderr_path and stdout_path in unicorn.rb since it runs a case statement on them. * Decode tag name before passing it into a TagFollowingAction [#4027](https://github.com/diaspora/diaspora/issues/4027) * Fix reshares in single post-view [#4056](https://github.com/diaspora/diaspora/issues/4056) +* Fix mobile view of deleted reshares. [#4063](https://github.com/diaspora/diaspora/issues/4063) ## Refactor diff --git a/app/helpers/mobile_helper.rb b/app/helpers/mobile_helper.rb index 439410481..82ef76308 100644 --- a/app/helpers/mobile_helper.rb +++ b/app/helpers/mobile_helper.rb @@ -6,13 +6,13 @@ module MobileHelper def mobile_reshare_icon(post) if (post.public? || reshare?(post)) && (user_signed_in? && post.author != current_user.person) - root = reshare?(post) ? post.root : post + absolute_root = reshare?(post) ? post.absolute_root : post - if root.author != current_user.person_id + if absolute_root.author != current_user.person reshare = Reshare.where(:author_id => current_user.person_id, - :root_guid => root.guid).first + :root_guid => absolute_root.guid).first klass = reshare.present? ? "active" : "inactive" - link_to '', reshares_path(:root_guid => root.guid), :title => t('reshares.reshare.reshare_confirmation', :author => root.author_name), :class => "image_link reshare_action #{klass}" + link_to '', reshares_path(:root_guid => absolute_root.guid), :title => t('reshares.reshare.reshare_confirmation', :author => absolute_root.author_name), :class => "image_link reshare_action #{klass}" end end end diff --git a/features/reshare_mobile.feature b/features/reshare_mobile.feature new file mode 100644 index 000000000..a1b38b8c4 --- /dev/null +++ b/features/reshare_mobile.feature @@ -0,0 +1,45 @@ +@javascript +Feature: resharing from the mobile + In order to make Diaspora more viral + As a mobile user + I want to reshare my friend's post + + Background: + Given following users exist: + | username | email | + | Bob Jones | bob@bob.bob | + | Alice Smith | alice@alice.alice | + | Eve Doe | eve@eve.eve | + And a user with email "bob@bob.bob" is connected with "alice@alice.alice" + Given "bob@bob.bob" has a public post with text "reshare this!" + And I sign in as "alice@alice.alice" + + Scenario: Resharing a post from a single post page + When I toggle the mobile view + And I preemptively confirm the alert + And I click on selector "a.image_link.reshare_action.inactive" + And I wait for the ajax to finish + Then I go to the stream page + And I should see "reshared via" within ".reshare_via" + + Scenario: Resharing a post from a single post page that is reshared + Given the post with text "reshare this!" is reshared by "eve@eve.eve" + And a user with email "alice@alice.alice" is connected with "eve@eve.eve" + When I toggle the mobile view + And I preemptively confirm the alert + And I click on the first selector "a.image_link.reshare_action.inactive" + And I wait for the ajax to finish + Then I go to the stream page + And I should see "reshared via" within ".reshare_via" + + Scenario: Delete original reshared post + Given "alice@alice.alice" has a public post with text "Don't reshare this!" + And the post with text "Don't reshare this!" is reshared by "bob@bob.bob" + And I am on "alice@alice.alice"'s page + And I preemptively confirm the alert + When I click to delete the first post + And I wait for the ajax to finish + And I log out + And I sign in as "bob@bob.bob" + And I toggle the mobile view + Then I should see "Original post deleted by author." within ".reshare" diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index c561ca5da..f0b2d79bc 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -150,6 +150,10 @@ And /^I click on selector "([^"]*)"$/ do |selector| page.execute_script("$('#{selector}').click();") end +And /^I click on the first selector "([^"]*)"$/ do |selector| + page.execute_script("$('#{selector}').first().click();") +end + And /^I preemptively confirm the alert$/ do page.evaluate_script("window.confirm = function() { return true; }") end