Skip to content

Instantly share code, notes, and snippets.

@jperrine
Created December 29, 2010 00:50
Show Gist options
  • Save jperrine/757975 to your computer and use it in GitHub Desktop.
Save jperrine/757975 to your computer and use it in GitHub Desktop.
# works
context "POST edit_subscriptions" do
setup do
fake_login
@user.subscriptions << Factory(:subscription)
@user.reminder_preferences << Factory(:reminder_preference)
post :edit_subscriptions, :params => {:commit => "Unsubscribe", :action => "edit_subscriptions", :id => @user.id, :controller => "users",
"#{@user.reminder_preferences.first.id}_email" => "on"}
assert_equal @user.reminder_preferences, []
should respond_with :redirect
should render_template :unsubscribe
end
end
# doesn't
context "POST edit_subscriptions" do
setup do
fake_login
@user.subscriptions << Factory(:subscription)
@user.reminder_preferences << Factory(:reminder_preference)
post :edit_subscriptions, :params => {:commit => "Unsubscribe", :action => "edit_subscriptions", :id => @user.id, :controller => "users",
"#{@user.reminder_preferences.first.id}_email" => "on"}
assert_equal @user.reminder_preferences, []
end
should respond_with :redirect
should render_template :unsubscribe
end
# this also works
context "GET unsubscribe" do
setup do
fake_login
get :unsubscribe, :id => @user.to_param
end
should render_template :unsubscribe
should respond_with :success
should assign_to :subscriptions
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment