diff options
Diffstat (limited to 'engines')
6 files changed, 24 insertions, 7 deletions
diff --git a/engines/billing/test/functional/subscriptions_controller_test.rb b/engines/billing/test/functional/subscriptions_controller_test.rb index 1e98eff..592ffc3 100644 --- a/engines/billing/test/functional/subscriptions_controller_test.rb +++ b/engines/billing/test/functional/subscriptions_controller_test.rb @@ -53,13 +53,13 @@ class SubscriptionsControllerTest < ActionController::TestCase test "subscribe creates subscription" do user = find_record :user - user.expects(:save).returns(true) login user payment_methods = [stub(:token => 'user_token')] Braintree::Customer.any_instance.stubs(:payment_methods).returns(payment_methods) - user.expects(:save).returns(true) + user.expects(:update_attributes).returns(true).twice post :subscribe, :id => "1", :first_name => "Test", :last_name => "Testing", :company => "RGSoC", :email => "any@email.com", :phone => "555-888-1234" + user.validate assert assigns(:result).success? assert_not_nil flash[:success] @@ -67,12 +67,13 @@ class SubscriptionsControllerTest < ActionController::TestCase test "unsubscribe cancels subscription" do user = find_record :user - user.expects(:save).returns(true) result = Braintree::Subscription.create(payment_method_token: 'user_token', plan_id: '1') user.subscription_id = result.subscription.id login user + user.expects(:update_attributes).returns(true) delete :unsubscribe, :id => "1" + user.validate assert assigns(:result).success? assert_not_nil flash[:success] diff --git a/engines/support/app/controllers/tickets_controller.rb b/engines/support/app/controllers/tickets_controller.rb index 8cccc2f..c20ef6a 100644 --- a/engines/support/app/controllers/tickets_controller.rb +++ b/engines/support/app/controllers/tickets_controller.rb @@ -19,7 +19,7 @@ class TicketsController < ApplicationController end def create - @ticket = Ticket.new(params[:ticket]) + @ticket = Ticket.new ticket_params #protecting posted_by isn't working, so this should protect it: @ticket.comments.last.posted_by = current_user.id @@ -89,6 +89,12 @@ class TicketsController < ApplicationController @title = t("layouts.title.tickets") end + def ticket_params + # make sure we have everything we need... + params.require(:ticket).require(:comments_attributes).require('0') + params.require(:ticket) + end + private # diff --git a/engines/support/app/mailers/ticket_mailer.rb b/engines/support/app/mailers/ticket_mailer.rb index 9a83345..38f9a39 100644 --- a/engines/support/app/mailers/ticket_mailer.rb +++ b/engines/support/app/mailers/ticket_mailer.rb @@ -4,7 +4,7 @@ class TicketMailer < ActionMailer::Base def self.send_notice(ticket, comment, url) reply_recipients(ticket, comment.user).each do |email, key| - TicketMailer.notice(ticket, comment, url, email, key).deliver + TicketMailer.notice(ticket, comment, url, email, key).deliver_now end end diff --git a/engines/support/test/functional/tickets_controller_test.rb b/engines/support/test/functional/tickets_controller_test.rb index 5c2b346..2f1e661 100644 --- a/engines/support/test/functional/tickets_controller_test.rb +++ b/engines/support/test/functional/tickets_controller_test.rb @@ -78,6 +78,16 @@ class TicketsControllerTest < ActionController::TestCase assert_nil assigns(:tickets).detect{|t| t.created_by != @user} end + + test "should rerender form on missing info" do + params = { :subject => "unauth ticket test subject", + :comments_attributes => {"0" => {}} + } + assert_raises ActionController::ParameterMissing do + post :create, :ticket => params + end + end + test "should create unauthenticated ticket" do params = {:subject => "unauth ticket test subject", :comments_attributes => {"0" => {"body" =>"body of test ticket"}}} diff --git a/engines/support/test/unit/account_extension_test.rb b/engines/support/test/unit/account_extension_test.rb index 0ecb1aa..1b97062 100644 --- a/engines/support/test/unit/account_extension_test.rb +++ b/engines/support/test/unit/account_extension_test.rb @@ -10,7 +10,7 @@ class AccountExtensionTest < ActiveSupport::TestCase t = FactoryGirl.create :ticket_with_creator u = t.created_by_user Account.new(u).destroy - assert_equal nil, Ticket.find(t.id) + assert_nil Ticket.find(t.id) end end diff --git a/engines/support/test/unit/ticket_test.rb b/engines/support/test/unit/ticket_test.rb index 373f06c..048704c 100644 --- a/engines/support/test/unit/ticket_test.rb +++ b/engines/support/test/unit/ticket_test.rb @@ -42,7 +42,7 @@ class TicketTest < ActiveSupport::TestCase t = FactoryGirl.create :ticket_with_creator u = t.created_by_user Ticket.destroy_all_from(u) - assert_equal nil, Ticket.find(t.id) + assert_nil Ticket.find(t.id) end =begin # TODO: do once have current_user stuff in order |