From 9769dfb303add2821c37c1040f0105477837e800 Mon Sep 17 00:00:00 2001 From: Dennis Collinson Date: Thu, 23 Feb 2012 17:23:52 -0800 Subject: [PATCH] cukes passing --- app/controllers/photos_controller.rb | 48 ------ app/controllers/reshares_controller.rb | 2 +- app/views/photos/show.html.haml | 63 ------- app/views/photos/show.mobile.haml | 17 -- features/comments.feature | 27 +-- features/photos.feature | 64 -------- features/step_definitions/comment_steps.rb | 7 +- features/support/paths.rb | 4 - public/javascripts/app/models/post.js | 1 + public/javascripts/app/models/reshare.js | 6 +- .../post-viewer/new-comment.handlebars | 2 +- public/javascripts/app/views/feedback_view.js | 2 - spec/controllers/photos_controller_spec.rb | 155 ------------------ 13 files changed, 16 insertions(+), 382 deletions(-) delete mode 100644 app/views/photos/show.html.haml delete mode 100755 app/views/photos/show.mobile.haml delete mode 100644 features/photos.feature diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index efff2f0cd..c2d1978da 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -5,8 +5,6 @@ class PhotosController < ApplicationController before_filter :authenticate_user!, :except => :show - helper_method :parent, :photo, :additional_photos, :next_photo, :previous_photo, :ownership - respond_to :html, :json def index @@ -143,22 +141,6 @@ class PhotosController < ApplicationController end end - def show - if user_signed_in? - @photo = current_user.find_visible_shareable_by_id(Photo, params[:id]) - else - @photo = Photo.where(:id => params[:id], :public => true).first - end - - if @photo - respond_with @photo - elsif user_signed_in? - redirect_to :back - else - redirect_to new_user_session_path - end - end - def edit if @photo = current_user.photos.where(:id => params[:id]).first respond_with @photo @@ -187,36 +169,6 @@ class PhotosController < ApplicationController end end - # helpers - - def ownership - @ownership ||= (current_user.present? && current_user.owns?(photo)) - end - - def parent - @parent ||= StatusMessage.where(:guid => photo.status_message_guid).includes(:photos).first if photo.status_message_guid - @parent ||= photo - end - - def photo - @photo ||= current_user.find_visible_shareable_by_id(Photo, params[:id]) - end - - def additional_photos - if photo.status_message_guid? - @additional_photos ||= photo.status_message.photos - end - end - - def next_photo - @next_photo ||= additional_photos[additional_photos.index(photo)+1] - @next_photo ||= additional_photos.first - end - - def previous_photo - @previous_photo ||= additional_photos[additional_photos.index(photo)-1] - end - private def file_handler(params) diff --git a/app/controllers/reshares_controller.rb b/app/controllers/reshares_controller.rb index 2b21b66ab..abda89664 100644 --- a/app/controllers/reshares_controller.rb +++ b/app/controllers/reshares_controller.rb @@ -9,6 +9,6 @@ class ResharesController < ApplicationController current_user.dispatch_post(@reshare, :url => post_url(@reshare), :additional_subscribers => @reshare.root.author) end - render :json => PostPresenter.new(@reshare.root, current_user).to_json, :status => 201 + render :json => PostPresenter.new(@reshare, current_user).to_json, :status => 201 end end diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml deleted file mode 100644 index f9805f232..000000000 --- a/app/views/photos/show.html.haml +++ /dev/null @@ -1,63 +0,0 @@ --# Copyright (c) 2010-2011, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3 or later. See --# the COPYRIGHT file. - -- content_for :head do - = include_javascripts :photos - -.span-16.append-4.prepend-4.last - #photo_controls - -if additional_photos && additional_photos.length > 1 - .right - =link_to "← #{t('previous')}", previous_photo, :rel => 'prefetch', :id => 'photo_show_left' - \/ - =link_to "#{t('next')} →", next_photo, :rel => 'prefetch', :id => 'photo_show_right' - - #original_post_info - = render 'shared/author_info', :person => photo.author, :post => photo - - #photo_container - #show_photo{:data=>{:guid=>photo.id}} - -if ownership - = image_tag 'ajax-loader.gif', :id => "photo_spinner", :class => "hidden" - = image_tag photo.url(:scaled_full) - -else - = image_tag photo.url(:scaled_full) - - #caption - = photo.text - - - if ownership - .photo_options{:data=>{:actor=>"#{photo.author.owner.id}", :actor_person => "#{photo.author.id}", :image_url => "#{photo.url(:thumb_large)}"}} - = link_to t('.make_profile_photo'), photo_make_profile_photo_path(photo), :method => :put, :remote => true, :class => 'make_profile_photo' - | - = link_to t('.edit'), '#', :id => "edit_photo_toggle" - %br - - %hr - - - if photo.status_message - - .span-8.last - %p - = markdownify(photo.status_message, :oembed => true) - %span{:style=>'font-size:smaller'} - =link_to t('.collection_permalink'), post_path(photo.status_message) - %br - %br - - .span-7.prepend-1 - .show_photo_attachments - - for _photo in additional_photos - = link_to (image_tag _photo.url(:thumb_small), :class => 'thumb_small'), photo_path(_photo) - - - #photo_edit_options - %h4= t('.edit_delete_photo') - - if photo.status_message - %p - = form_for photo, :remote => true do |p| - = p.text_field :text, :value => photo.text - = p.submit t('.update_photo') - %p - = button_to t('.delete_photo'), photo, :confirm => t('are_you_sure'), :method => :delete diff --git a/app/views/photos/show.mobile.haml b/app/views/photos/show.mobile.haml deleted file mode 100755 index 96a0a0ca9..000000000 --- a/app/views/photos/show.mobile.haml +++ /dev/null @@ -1,17 +0,0 @@ --# Copyright (c) 2010-2011, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3 or later. See --# the COPYRIGHT file. - - -#show_content.photo - = image_tag photo.url(:scaled_full) - - -if additional_photos && additional_photos.length > 1 - #photo_controls - %table - %tr - %td - =link_to "←", previous_photo, :rel => 'prefetch', :class => 'arrow' - %td{:width => '100%'} - %td - =link_to "→", next_photo, :rel => 'prefetch', :class => 'arrow' diff --git a/features/comments.feature b/features/comments.feature index 0ae883b8d..05064ddcd 100644 --- a/features/comments.feature +++ b/features/comments.feature @@ -20,26 +20,6 @@ Feature: commenting Then I should see "is that a poodle?" within ".comment" And I should see "less than a minute ago" within ".comment time" - Scenario: comment on a photo from the photo page - When I sign in as "bob@bob.bob" - And I am on the photo page for "alice@alice.alice"'s post "Look at this dog" - And I wait for the ajax to finish - And I focus the comment field - And I fill in "text" with "hahahah" - And I press "Comment" - Then I should see "hahaha" within ".comment" - And I should see "less than a minute ago" within ".comment time" - - Scenario: comment on your own photo from the photo page - When I sign in as "alice@alice.alice" - And I am on the photo page for "alice@alice.alice"'s post "Look at this dog" - And I wait for the ajax to finish - And I focus the comment field - And I fill in "text" with "hahahah" - And I press "Comment" - Then I should see "hahaha" within ".comment" - And I should see "less than a minute ago" within ".comment time" - Scenario: delete a comment When I sign in as "bob@bob.bob" And I am on "alice@alice.alice"'s page @@ -73,9 +53,6 @@ Feature: commenting Then I should see "Look at this dog" When I follow "less than a minute ago" Then I should see "Look at this dog" - When I focus the comment field - And I fill in "text" with "I think thats a cat" - And I press "Comment" - And I wait for the ajax to finish - When I am on "alice@alice.alice"'s page + And I make a show page comment "I think thats a cat" + When I go to "alice@alice.alice"'s page Then I should see "I think thats a cat" diff --git a/features/photos.feature b/features/photos.feature deleted file mode 100644 index 90debbf21..000000000 --- a/features/photos.feature +++ /dev/null @@ -1,64 +0,0 @@ -@javascript -Feature: photos - In order to enlighten humanity for the good of society - As a rock star - I want to post pictures of a button - - Background: - Given a user with username "bob" - When I sign in as "bob@bob.bob" - - And I am on the home page - - Scenario: deleting a photo will delete a photo-only post if the photo was the last image - 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 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 go to the home page - - Then I should not see any posts in my stream - - 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" - - diff --git a/features/step_definitions/comment_steps.rb b/features/step_definitions/comment_steps.rb index ae7530e5b..b2a207fc6 100644 --- a/features/step_definitions/comment_steps.rb +++ b/features/step_definitions/comment_steps.rb @@ -10,7 +10,12 @@ Then /^the first comment field should be closed$/ do find("#main_stream .stream_element .new_comment").should_not be_visible end - When /^I comment "([^"]*)" on "([^"]*)"$/ do |comment_text, post_text| comment_on_post(post_text, comment_text) end + +When /^I make a show page comment "([^"]*)"$/ do |comment_text| + find(".label.comment").click + fill_in "new-comment-text", :with => comment_text + click_button :submit +end \ No newline at end of file diff --git a/features/support/paths.rb b/features/support/paths.rb index 862de6851..b6eb520df 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -27,10 +27,6 @@ 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).photos.last) - when /^the photo page for "([^\"]*)"'s post "([^\"]*)"$/ - post_path(User.find_by_email($1).posts.find_by_text($2)) when /^"(\/.*)"/ $1 else diff --git a/public/javascripts/app/models/post.js b/public/javascripts/app/models/post.js index 7ee899fdb..3eb192505 100644 --- a/public/javascripts/app/models/post.js +++ b/public/javascripts/app/models/post.js @@ -71,6 +71,7 @@ app.models.Post = Backbone.Model.extend({ self.set(resp.get("post")) self.trigger('interacted', self) }}); + }, unlike : function() { diff --git a/public/javascripts/app/models/reshare.js b/public/javascripts/app/models/reshare.js index 767278707..52674f176 100644 --- a/public/javascripts/app/models/reshare.js +++ b/public/javascripts/app/models/reshare.js @@ -1,6 +1,6 @@ app.models.Reshare = app.models.Post.extend({ rootPost : function(){ - this._rootPost = this._rootPost || new app.models.Post(this.get("root")) + this._rootPost = this._rootPost || new app.models.Post(this.get("root")); return this._rootPost }, @@ -10,5 +10,9 @@ app.models.Reshare = app.models.Post.extend({ reshareAuthor : function(){ return this.rootPost().reshareAuthor() + }, + + parse: function(resp){ + return resp.post } }); diff --git a/public/javascripts/app/templates/post-viewer/new-comment.handlebars b/public/javascripts/app/templates/post-viewer/new-comment.handlebars index f16af3c6a..c919e2113 100644 --- a/public/javascripts/app/templates/post-viewer/new-comment.handlebars +++ b/public/javascripts/app/templates/post-viewer/new-comment.handlebars @@ -1,6 +1,6 @@
- +