Permalink
Browse files

ConvesationsController#follow is now SubscribersController#create.

  • Loading branch information...
1 parent 18b41b3 commit 8255b1f176d5d5cf0048ed0874929789ded6c42e Waseem Ahmad committed Jan 17, 2010
@@ -117,12 +117,6 @@ def create
end
#----------------------------------------------------------------------------
- def follow
- @conversation = Conversation.find(params[:id])
- current_user.follow(@conversation, params[:token])
- end
-
- #----------------------------------------------------------------------------
def follow_with_token
current_user.follow(@conversation, params[:token])
redirect_to @conversation
@@ -139,11 +133,6 @@ def follow_email_with_token
end
#----------------------------------------------------------------------------
- def follow_from_list
- follow
- end
-
- #----------------------------------------------------------------------------
def unfollow
@conversation = Conversation.find(params[:id])
current_user.unfollow(@conversation)
@@ -12,9 +12,18 @@ def index
format.html
format.xml { render :xml => { :subscribers => @subscribers } }
else
- flash[:error] = "Sorry, this is a private conversation. You can try anoter one"
+ flash[:error] = "Sorry, this is a private conversation. You can try another one"
format.html { redirect_to conversations_path }
end
end
end
+
+ def create
+ @conversation = Conversation.find(params[:conversation_id])
+ current_user.follow(@conversation, params[:token])
+
+ respond_to do |format|
+ format.js
+ end
+ end
end
@@ -11,6 +11,6 @@
<%= conversation.date_time12 %> -
<%= pluralize conversation.messages.size, 'message' %> -
<%= pluralize conversation.subscriptions.size, 'follower' %> -
- <%= render :partial => 'conversations/follow_from_list', :object => conversation %>
+ <%= render :partial => 'conversations/follow_from_list', :locals => { :conversation => conversation } %>
</span>
</li>
@@ -3,7 +3,7 @@
<% if follow.followed_by?(current_user) %>
<%= link_to_remote t("ui.unfollow"), :url => unfollow_conversation_path(follow) %>
<% else %>
- <%= link_to_remote t("ui.follow"), :url => follow_conversation_path(follow) %>
+ <%= link_to_remote t("ui.follow"), :url => conversation_subscribers_path(follow) %>
<% end %>
</span>
<% end %>
@@ -1,10 +1,10 @@
<% if logged_in? %>
- <span id="follow_conversation_<%=follow_from_list.id-%>">
- <% if follow_from_list.followed_by?(current_user) %>
- <%= "&#187; " + link_to_remote( t("ui.unfollow"), :url => unfollow_from_list_conversation_path(follow_from_list) ) %>
+ <span id="follow_conversation_<%=conversation.id-%>">
+ <% if conversation.followed_by?(current_user) %>
+ <%= "&#187; " + link_to_remote( t("ui.unfollow"), :url => unfollow_from_list_conversation_path(conversation) ) %>
<% else %>
- <% if !follow_from_list.private? || follow_from_list.user_id == current_user.id %>
- <%= "&#187; " + link_to_remote( t("ui.follow"), :url => follow_from_list_conversation_path(follow_from_list) ) %>
+ <% if !conversation.private? || conversation.user_id == current_user.id %>
+ <%= "&#187; " + link_to_remote( t("ui.follow"), :url => conversation_subscribers_path(conversation) ) %>
<% end %>
<% end %>
</span>
@@ -0,0 +1,9 @@
+<% if logged_in? %>
+ <span id="follow_conversation_<%=conversation.id-%>">
+ <% if conversation.followed_by?(current_user) %>
+ <%= link_to_remote t("ui.unfollow"), :url => unfollow_conversation_path(conversation) %>
+ <% else %>
+ <%= link_to_remote t("ui.follow"), :url => conversation_subscribers_path(conversation) %>
+ <% end %>
+ </span>
+<% end %>
@@ -1,4 +1,4 @@
-page.replace "follow_conversation_#{@conversation.id}", :partial => 'follow', :object => @conversation
+page.replace "follow_conversation_#{@conversation.id}", :partial => 'follow', :locals => { :conversation => @conversation }
page.replace "news", :partial => 'users/news'
# page.replace "users_in_conversation", :partial => 'conversations/users_in_conversation'
page["follow_conversation_#{@conversation.id}"].visual_effect :pulsate
View
@@ -24,11 +24,9 @@
:toggle_private_status => :put,
:toggle_readwrite_status => :put,
:toggle_bookmark => :post,
- :follow => :post,
:follow_with_token => :get,
:follow_email_with_token => :get,
:unfollow => :post,
- :follow_from_list => :post,
:unfollow_from_list => :post,
:invite => :get,
:invite_from_list => :post,
@@ -292,31 +292,6 @@ def setup
end
end # context toggle_private_status action
- context "follow action" do
- setup do
- @convo = Factory.create( :conversation )
- Conversation.stubs( :find ).returns( @convo )
- @subscription = Factory.create( :subscription, :conversation => @convo )
- @convo.stubs( :add_subscription ).returns( @subscription )
- end
-
- should "be success" do
- xhr :post, :follow, :id => '1'
- assert_response 200
- end
-
- should "call add_subscription" do
- Conversation.expects( :find ).with( '1' ).returns( @convo )
- @convo.expects( :add_subscription ).with( @current_user ).returns( @subscription )
- xhr :post, :follow, :id => '1'
- end
-
- should "mark subscription as read" do
- @subscription.expects( :mark_read! )
- xhr :post, :follow, :id => '1'
- end
- end # context follow action
-
context "unfollow action" do
setup do
@convo = Factory.create( :conversation )
@@ -2,13 +2,13 @@
class SubscribersControllerTest < ActionController::TestCase
- context "index action" do
- setup do
- @current_user = create_user_and_authenticate
- @convo = Factory.create(:conversation)
- @subscription = Factory.create(:subscription, :conversation => @convo, :user => @current_user)
- end
+ def setup
+ @current_user = create_user_and_authenticate
+ @convo = Factory.create(:conversation)
+ @subscription = Factory.create(:subscription, :conversation => @convo, :user => @current_user)
+ end
+ context "index action" do
context "html request" do
should "be successful for public convo" do
get :index, :conversation_id => @convo.id
@@ -19,8 +19,15 @@ class SubscribersControllerTest < ActionController::TestCase
@conv = Factory.create(:conversation, :private => true)
get :index, :conversation_id => @conv.id
assert_response 302
- assert_equal flash[:error], "Sorry, this is a private conversation. You can try anoter one"
+ assert_equal flash[:error], "Sorry, this is a private conversation. You can try another one"
end
end
end
+
+ context "create action" do
+ should "be success" do
+ xhr :post, :create, :conversation_id => @convo.id
+ assert_response 200
+ end
+ end
end

0 comments on commit 8255b1f

Please sign in to comment.