Skip to content

Commit

Permalink
Merge pull request #1692 from sarken/issue_3845
Browse files Browse the repository at this point in the history
3845 Associations ul and tests
  • Loading branch information
CristinaRO committed Jun 1, 2014
2 parents 6671aa3 + 329285a commit 35c9d4e
Show file tree
Hide file tree
Showing 9 changed files with 305 additions and 149 deletions.
8 changes: 4 additions & 4 deletions app/helpers/works_helper.rb
Expand Up @@ -164,10 +164,10 @@ def show_work_notes?(work)

# Returns true or false to determine whether the work associations should be included
def show_associations?(work)
@work.recipients ||
@work.approved_related_works.where(translation: true).exists? ||
@work.parent_work_relationships ||
@work.challenge_claims
work.recipients.present? ||
work.approved_related_works.where(translation: true).exists? ||
work.parent_work_relationships.exists? ||
work.challenge_claims.present?
end


Expand Down
47 changes: 28 additions & 19 deletions features/other/gift.feature
Expand Up @@ -10,21 +10,22 @@ Feature: Create Gifts
| gifter | something | gifter@foo.com |
| giftee1 | something | giftee1@foo.com |
| giftee2 | something | giftee2@foo.com |
| associate | something | associate@foo.com |
And I am logged in as "gifter" with password "something"
And I set up the draft "GiftStory1"


Scenario: Giving a work as a gift when posting directly

Given I fill in "work_recipients" with "giftee1"
Given I give the work to "giftee1"
When I press "Post Without Preview"
Then I should see "For giftee1"
And "giftee1@foo.com" should be notified by email about their gift "GiftStory1"


Scenario: Giving a work as a gift when posting after previewing

Given I fill in "work_recipients" with "giftee1"
Given I give the work to "giftee1"
And I press "Preview"
And I should see "For giftee1"
And 0 emails should be delivered
Expand All @@ -37,7 +38,7 @@ Feature: Create Gifts

Given I press "Preview"
And I press "Edit"
And I fill in "work_recipients" with "giftee1"
And I give the work to "giftee1"
And I press "Preview"
And 0 emails should be delivered
When I press "Post"
Expand All @@ -49,7 +50,7 @@ Feature: Create Gifts

Given I press "Post Without Preview"
And I follow "Edit"
And I fill in "work_recipients" with "giftee1"
And I give the work to "giftee1"
When I press "Post Without Preview"
Then I should see "For giftee1"
And "giftee1@foo.com" should be notified by email about their gift "GiftStory1"
Expand All @@ -59,7 +60,7 @@ Feature: Create Gifts

Given I press "Post Without Preview"
And I follow "Edit"
And I fill in "work_recipients" with "giftee1"
And I give the work to "giftee1"
And I press "Preview"
And 0 emails should be delivered
And I press "Edit"
Expand All @@ -72,10 +73,10 @@ Feature: Create Gifts

Scenario: Give two gifts to the same recipient

Given I fill in "work_recipients" with "giftee1"
Given I give the work to "giftee1"
And I press "Post Without Preview"
And I set up the draft "GiftStory2"
And I fill in "work_recipients" with "giftee1"
And I give the work to "giftee1"
When I press "Post Without Preview"
And I follow "giftee1"
Then I should see "Gifts for giftee1"
Expand All @@ -85,13 +86,13 @@ Feature: Create Gifts

Scenario: Add another recipient to a posted gift

Given I fill in "work_recipients" with "giftee1"
Given I give the work to "giftee1"
And I press "Post Without Preview"
And I should see "For giftee1"
And "giftee1@foo.com" should be notified by email about their gift "GiftStory1"
And all emails have been delivered
And I follow "Edit"
And I fill in "work_recipients" with "giftee1, giftee2"
And I give the work to "giftee1, giftee2"
When I press "Post Without Preview"
Then I should see "For giftee1, giftee2"
And 0 emails should be delivered to "giftee1@foo.com"
Expand All @@ -100,12 +101,12 @@ Feature: Create Gifts

Scenario: Add another recipient to a draft gift

Given I fill in "work_recipients" with "giftee1"
Given I give the work to "giftee1"
And I press "Preview"
And I should see "For giftee1"
And 0 emails should be delivered to "giftee1@foo.com"
And I press "Edit"
And I fill in "work_recipients" with "giftee1, giftee2"
And I give the work to "giftee1, giftee2"
When I press "Post Without Preview"
Then I should see "For giftee1, giftee2"
And "giftee1@foo.com" should be notified by email about their gift "GiftStory1"
Expand All @@ -114,14 +115,14 @@ Feature: Create Gifts

Scenario: Add two recipients, post, then remove one

Given I fill in "work_recipients" with "giftee1, giftee2"
Given I give the work to "giftee1, giftee2"
And I press "Post Without Preview"
And I should see "For giftee1, giftee2"
And "giftee1@foo.com" should be notified by email about their gift "GiftStory1"
And "giftee2@foo.com" should be notified by email about their gift "GiftStory1"
And all emails have been delivered
And I follow "Edit"
And I fill in "work_recipients" with "giftee1"
And I give the work to "giftee1"
When I press "Post Without Preview"
Then I should see "For giftee1"
And I should not see "giftee2"
Expand All @@ -131,12 +132,12 @@ Feature: Create Gifts

Scenario: Add two recipients, preview, then remove one

Given I fill in "work_recipients" with "giftee1, giftee2"
Given I give the work to "giftee1, giftee2"
And I press "Preview"
And I should see "For giftee1, giftee2"
And 0 emails should be delivered
And I press "Edit"
And I fill in "work_recipients" with "giftee1"
And I give the work to "giftee1"
When I press "Post Without Preview"
Then I should see "For giftee1"
And I should not see "giftee2"
Expand All @@ -146,13 +147,13 @@ Feature: Create Gifts

Scenario: Edit a posted work to replace one recipient with another

Given I fill in "work_recipients" with "giftee1"
Given I give the work to "giftee1"
And I press "Post Without Preview"
And I should see "For giftee1"
And "giftee1@foo.com" should be notified by email about their gift "GiftStory1"
And all emails have been delivered
And I follow "Edit"
And I fill in "work_recipients" with "giftee2"
And I give the work to "giftee2"
When I press "Post Without Preview"
Then I should see "For giftee2"
And I should not see "giftee1"
Expand All @@ -162,14 +163,22 @@ Feature: Create Gifts

Scenario: Edit a draft to replace one recipient with another

Given I fill in "work_recipients" with "giftee1"
Given I give the work to "giftee1"
And I press "Preview"
And I should see "For giftee1"
And 0 emails should be delivered
And I press "Edit"
And I fill in "work_recipients" with "giftee2"
And I give the work to "giftee2"
When I press "Post Without Preview"
Then I should see "For giftee2"
And I should not see "giftee1"
And 0 emails should be delivered to "giftee1@foo.com"
And "giftee2@foo.com" should be notified by email about their gift "GiftStory1"


Scenario: A gift work should have an associations list

Given I give the work to "associate"
When I press "Post Without Preview"
Then I should find a list for associations
And I should see "For associate"
Expand Up @@ -36,6 +36,8 @@ Feature: Prompt Meme Challenge
Given all emails have been delivered
And I press "Post Without Preview"
Then I should see "Kinky Story"
And I should find a list for associations
And I should see "In response to a prompt by Anonymous in the promptcollection collection"
# TODO: Figure out why this isn't working
# email the anonymous prompter that they've received a fill!
# And 1 email should be delivered to "my1@e.org"
Expand Down
116 changes: 93 additions & 23 deletions features/step_definitions/work_related_steps.rb
Expand Up @@ -13,17 +13,53 @@
step "I am logged out"
end

Given /^an inspiring parent work has been posted$/ do
step %{I post an inspiring parent work as testy}
end

# given for remixes / related works

Given /^a related work has been posted$/ do
step %{I post a related work as remixer}
end

Given /^a related work has been posted and approved$/ do
step %{I post a related work as remixer}
step %{I approve a related work}
end

# given for translations

Given /^a translation has been posted$/ do
step "I post a translation"
step %{I post a translation as translator}
end

Given /^a remix has been posted$/ do
step "I post a related work"
Given /^a translation has been posted and approved$/ do
step %{I post a translation as translator}
step %{I approve a related work}
end

### WHEN

When /^I post a related work$/ do
When /^I post an inspiring parent work as testy$/ do
step %{I am logged in as "testuser"}
step %{I post the work "Parent Work"}
end

When /^I approve a related work$/ do
step %{I am logged in as "inspiration"}
step %{I go to my related works page}
step %{I follow "Approve"}
step %{I press "Yes, link me!"}
end

When /^I view my related works$/ do
step %{I go to my related works page}
end

# when for remixes / related works

When /^I post a related work as remixer$/ do
step %{I am logged in as "remixer"}
step %{I go to the new work page}
step %{I select "Not Rated" from "Rating"}
Expand All @@ -36,15 +72,17 @@
step %{I press "Post"}
end

When /^I post a translation$/ do
# when for translations

When /^I post a translation as translator$/ do
step %{I am logged in as "translator"}
step %{I draft a translation}
step %{I draft a translation}
step %{I press "Post"}
end

When /^I post a translation of my own work$/ do
step %{I am logged in as "inspiration"}
step %{I draft a translation}
step %{I draft a translation}
step %{I press "Post"}
end

Expand All @@ -59,30 +97,62 @@
step %{I press "Preview"}
end

When /^I approve a related work$/ do
step %{I am logged in as "inspiration"}
step "I am on my user page"
step %{I follow "Related Works"}
step %{I follow "Approve"}
step %{I press "Yes, link me!"}
### THEN

Then /^the original author should be emailed$/ do
step "1 email should be delivered"
end

When /^I view my related works$/ do
step "I go to my user page"
step %{I follow "Related Works"}
Then /^approving the related work should succeed$/ do
step %{I should see "Link was successfully approved"}
end

### THEN
# then for remixes / related works

Then /^a related work should be seen$/ do
Then /^a parent related work should be seen$/ do
step %{I should see "Work was successfully posted"}
step %{I should see "Inspired by Worldbuilding by inspiration"}
step %{I should find a list for associations}
step %{I should see "Inspired by Worldbuilding by inspiration" within ".preface .notes"}
end

Then /^the original author should be emailed$/ do
step "1 email should be delivered"
Then /^I should see the inspiring parent work in the beginning notes$/ do
step %{I should see "Inspired by Parent Work by testuser" within ".preface .notes"}
end

Then /^approving the related work should succeed$/ do
step %{I should see "Link was successfully approved"}
Then /^I should see a beginning note about related works$/ do
step %{I should see "See the end of the work for other works inspired by this one" within ".preface .notes"}
end

Then /^I should see the related work in the end notes$/ do
step %{I should see "Works inspired by this one:" within ".afterword .children"}
step %{I should see "Followup by remixer" within ".afterword .children"}
end

Then /^I should not see the related work listed on the original work$/ do
step %{I should not see "See the end of the work for other works inspired by this one"}
step %{I should not see "Works inspired by this one:"}
step %{I should not see "Followup by remixer"}
end

# then for translations

Then /^a parent translated work should be seen$/ do
step %{I should see "Work was successfully posted"}
step %{I should find a list for associations}
step %{I should see "A translation of Worldbuilding by inspiration" within ".preface .notes"}
end

Then /^I should see the translation in the beginning notes$/ do
step %{I should see "Translation into Deutsch available:" within ".preface .notes"}
step %{I should see "Worldbuilding Translated by translator" within ".preface .notes"}
end

Then /^I should not see the translation listed on the original work$/ do
step %{I should not see "Translation into Deutsch available:"}
step %{I should not see "Worldbuilding Translated by translator"}
end

Then /^I should not see the translation in the end notes$/ do
step %{I should not see "Translation into Deutsch available:" within ".afterword"}
step %{I should not see "Worldbuilding Translated by translator" within ".afterword"}
end

0 comments on commit 35c9d4e

Please sign in to comment.