wip holding off until the follow model is done
This commit is contained in:
parent
597e71c216
commit
fb8b8ab7fc
7 changed files with 87 additions and 1 deletions
19
app/controllers/post_visibilities_controller.rb
Normal file
19
app/controllers/post_visibilities_controller.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
#
|
||||||
|
|
||||||
|
class PostVisibilitiesController < ApplicationController
|
||||||
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@vis = ConversationVisibility.where(:person_id => current_user.person.id,
|
||||||
|
:conversation_id => params[:conversation_id]).first
|
||||||
|
if @vis
|
||||||
|
if @vis.destroy
|
||||||
|
flash[:notice] = "Conversation successfully removed"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
redirect_to conversations_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
class AddHiddenToPostVisibilities < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :post_visibilities, :hidden, :boolean, :defalut => false, :null => false
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :post_visibilities, :hidden
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -215,6 +215,7 @@ ActiveRecord::Schema.define(:version => 20110330230206) do
|
||||||
t.integer "post_id", :null => false
|
t.integer "post_id", :null => false
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
t.boolean "hidden", :null => false
|
||||||
t.integer "contact_id", :null => false
|
t.integer "contact_id", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ Feature: commenting
|
||||||
Then I should see "hahaha" within "li.comment div.content"
|
Then I should see "hahaha" within "li.comment div.content"
|
||||||
And I should see "less than a minute ago" within "li.comment time"
|
And I should see "less than a minute ago" within "li.comment time"
|
||||||
|
|
||||||
Scenario: delete a post
|
Scenario: delete a comment
|
||||||
When I sign in as "bob@bob.bob"
|
When I sign in as "bob@bob.bob"
|
||||||
And I am on "alice@alice.alice"'s page
|
And I am on "alice@alice.alice"'s page
|
||||||
Then I should see "Look at this dog"
|
Then I should see "Look at this dog"
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,23 @@ Feature: posting
|
||||||
And I follow "All Aspects"
|
And I follow "All Aspects"
|
||||||
Then I should see "I am eating a yogurt" within ".stream_element"
|
Then I should see "I am eating a yogurt" within ".stream_element"
|
||||||
|
|
||||||
|
Scenario: hide a post
|
||||||
|
Given I expand the publisher
|
||||||
|
When I fill in "status_message_fake_text" with "I am eating a yogurt"
|
||||||
|
And I press "Share"
|
||||||
|
And I wait for the ajax to finish
|
||||||
|
|
||||||
|
And I log out
|
||||||
|
And I sign in as "alice@alice.alice"
|
||||||
|
And I am on "bob@bob.bob"'s page
|
||||||
|
|
||||||
|
And I hover over the post
|
||||||
|
And I preemptively confirm the alert
|
||||||
|
And I click to hide the first post
|
||||||
|
And I wait for the ajax to finish
|
||||||
|
And I follow "All Aspects"
|
||||||
|
Then I should not see "I am eating a yogurt"
|
||||||
|
|
||||||
Scenario: delete a post
|
Scenario: delete a post
|
||||||
Given I expand the publisher
|
Given I expand the publisher
|
||||||
When I fill in "status_message_fake_text" with "I am eating a yogurt"
|
When I fill in "status_message_fake_text" with "I am eating a yogurt"
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,10 @@ When /^I click to delete the first post$/ do
|
||||||
page.execute_script('$(".stream_element").first().find(".stream_element_delete").click()')
|
page.execute_script('$(".stream_element").first().find(".stream_element_delete").click()')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I click to hide the first post$/ do
|
||||||
|
page.execute_script('$(".stream_element").first().find(".stream_element_hide").click()')
|
||||||
|
end
|
||||||
|
|
||||||
When /^I click to delete the first comment$/ do
|
When /^I click to delete the first comment$/ do
|
||||||
page.execute_script('$(".comment.posted").first().find(".comment_delete").click()')
|
page.execute_script('$(".comment.posted").first().find(".comment_delete").click()')
|
||||||
end
|
end
|
||||||
|
|
|
||||||
36
spec/controllers/post_visibilities_controller_spec.rb
Normal file
36
spec/controllers/post_visibilities_controller_spec.rb
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe PostVisibilitiesController do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
before do
|
||||||
|
@user1 = alice
|
||||||
|
sign_in :user, @user1
|
||||||
|
|
||||||
|
|
||||||
|
status = @user1.post(:status_message, :text => "hello", :public => true, :to => 'all')
|
||||||
|
@vis = status.post_visibilities.first
|
||||||
|
pp @vis
|
||||||
|
@vis.reload.hidden.should == false
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#destroy' do
|
||||||
|
it 'deletes the visibility' do
|
||||||
|
delete :destroy, :conversation_id => @vis.id
|
||||||
|
@vis.reload.hidden.should == true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not let a user destroy a visibility that is not theirs' do
|
||||||
|
user2 = eve
|
||||||
|
sign_in :user, user2
|
||||||
|
|
||||||
|
lambda {
|
||||||
|
delete :destroy, :conversation_id => @vis.id
|
||||||
|
}.should_not change(@vis.reload, :hidden).to(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue