Have passing Cucumber tests [Finishes issue #1126]
This commit is contained in:
parent
98b71f92ab
commit
9d7b8d7f5d
5 changed files with 62 additions and 10 deletions
|
|
@ -128,7 +128,7 @@ class PhotosController < ApplicationController
|
|||
format.html do
|
||||
flash[:notice] = I18n.t 'photos.destroy.notice'
|
||||
if photo.status_message_guid
|
||||
if photo.status_message.empty?
|
||||
if photo.status_message.message_or_photos_present?
|
||||
photo.status_message.destroy
|
||||
respond_with photo, :location => person_photos_path(current_user.person)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class StatusMessage < Post
|
|||
xml_attr :raw_message
|
||||
|
||||
has_many :photos, :dependent => :destroy, :foreign_key => :status_message_guid, :primary_key => :guid
|
||||
validate :message_or_photos_present?
|
||||
validate :ensure_message_requirements
|
||||
|
||||
attr_accessible :text
|
||||
serialize :youtube_titles, Hash
|
||||
|
|
@ -134,19 +134,18 @@ class StatusMessage < Post
|
|||
|
||||
def comment_email_subject
|
||||
formatted_message(:plain_text => true)
|
||||
end
|
||||
end
|
||||
|
||||
def empty?
|
||||
def message_or_photos_present?
|
||||
self.text.blank? && self.photos == []
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def message_or_photos_present?
|
||||
if self.blank?
|
||||
def ensure_message_requirements
|
||||
if message_or_photos_present?
|
||||
errors[:base] << 'Status message requires a message or at least one photo'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,52 @@ Feature: photos
|
|||
Given I expand the publisher
|
||||
And I attach the file "spec/fixtures/button.png" to hidden element "file" within "#file-upload"
|
||||
And I wait for the ajax to finish
|
||||
Then I should see an uploaded image within the photo drop zone
|
||||
And I press "Share"
|
||||
And I wait for the ajax to finish
|
||||
And I follow "Your Aspects"
|
||||
Then I should see a "img" within ".stream_element div.photo_attachments"
|
||||
|
||||
When I go to the photo page for "bob@bob.bob"'s latest post
|
||||
And I follow "edit_photo_toggle"
|
||||
And I preemptively confirm the alert
|
||||
And I press "Delete Photo"
|
||||
And I wait for the ajax to finish
|
||||
And I go to the home page
|
||||
|
||||
Then I should see 0 posts
|
||||
|
||||
Scenario: deleting a photo will not delete a photo-only post if another photo remains attached
|
||||
Given I expand the publisher
|
||||
And I attach the file "spec/fixtures/button.png" to hidden element "file" within "#file-upload"
|
||||
And I wait for the ajax to finish
|
||||
And I attach the file "spec/fixtures/button.png" to hidden element "file" within "#file-upload"
|
||||
And I wait for the ajax to finish
|
||||
And I press "Share"
|
||||
And I wait for the ajax to finish
|
||||
|
||||
When I go to the photo page for "bob@bob.bob"'s latest post
|
||||
And I follow "edit_photo_toggle"
|
||||
And I preemptively confirm the alert
|
||||
And I press "Delete Photo"
|
||||
And I wait for the ajax to finish
|
||||
And I go to the home page
|
||||
|
||||
Then I should see 1 posts
|
||||
|
||||
Scenario: deleting a photo will not delete its parent post if the parent also contained text
|
||||
Given I expand the publisher
|
||||
And I fill in "status_message_fake_text" with "I am eating a yogurt"
|
||||
And I attach the file "spec/fixtures/button.png" to hidden element "file" within "#file-upload"
|
||||
And I wait for the ajax to finish
|
||||
And I press "Share"
|
||||
And I wait for the ajax to finish
|
||||
|
||||
When I go to the photo page for "bob@bob.bob"'s latest post
|
||||
And I follow "edit_photo_toggle"
|
||||
And I preemptively confirm the alert
|
||||
And I press "Delete Photo"
|
||||
And I wait for the ajax to finish
|
||||
And I go to the home page
|
||||
|
||||
Then I should see 1 posts
|
||||
And I should see "I am eating a yogurt" within ".stream_element"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -108,11 +108,19 @@ When /^I press the ([\d])(nd|rd|st|th) "([^\"]*)"(?: within "([^\"]*)")?$/ do |n
|
|||
find(:css, link_selector+":nth-child(#{number})").click
|
||||
end
|
||||
end
|
||||
|
||||
Then /^(?:|I )should see a "([^\"]*)"(?: within "([^\"]*)")?$/ do |selector, scope_selector|
|
||||
with_scope(scope_selector) do
|
||||
page.has_css?(selector).should be_true
|
||||
end
|
||||
end
|
||||
|
||||
Then /^(?:|I )should not see a "([^\"]*)"(?: within "([^\"]*)")?$/ do |selector, scope_selector|
|
||||
with_scope(scope_selector) do
|
||||
page.has_css?(selector).should be_false
|
||||
end
|
||||
end
|
||||
|
||||
Then /^I should see "([^\"]*)" in the main content area$/ do |stuff|
|
||||
within("#main_stream") do
|
||||
Then "I should see #{stuff}"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ module NavigationHelpers
|
|||
person_path(User.find_by_email($1).person)
|
||||
when /^my account settings page$/
|
||||
edit_user_path
|
||||
when /^the photo page for "([^\"]*)"'s latest post$/
|
||||
photo_path(User.find_by_email($1).posts.where(:type => "Photo").last)
|
||||
when /^the photo page for "([^\"]*)"'s post "([^\"]*)"$/
|
||||
photo_path(User.find_by_email($1).posts.find_by_text($2))
|
||||
when /^"(\/.*)"/
|
||||
|
|
|
|||
Loading…
Reference in a new issue