summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-12-03 08:55:49 +0100
committerAzul <azul@leap.se>2012-12-03 08:55:49 +0100
commit0b23df922336289b6f8062653b4d3e852ed927ec (patch)
treed0bc74c55ffa8b0ee6509df1798756585402cc4b
parent277b9f98bfbe2ef0217dfd17c8d9d6597369b903 (diff)
make tests pass on an empty db
-rw-r--r--help/app/controllers/tickets_controller.rb8
-rw-r--r--help/test/functional/tickets_controller_test.rb2
-rw-r--r--users/test/support/stub_record_helper.rb2
3 files changed, 6 insertions, 6 deletions
diff --git a/help/app/controllers/tickets_controller.rb b/help/app/controllers/tickets_controller.rb
index 4c7415b..b5f3a63 100644
--- a/help/app/controllers/tickets_controller.rb
+++ b/help/app/controllers/tickets_controller.rb
@@ -14,7 +14,7 @@ class TicketsController < ApplicationController
@ticket.created_by = current_user.id
@ticket.email = current_user.email if current_user.email
@ticket.comments.last.posted_by = current_user.id
- else
+ else
@ticket.comments.last.posted_by = nil #hacky, but protecting this attribute doesn't work right, so this should make sure it isn't set.
end
@@ -36,11 +36,11 @@ class TicketsController < ApplicationController
# @ticket.comments.build
# build ticket comments?
end
-
+
def update
@ticket = Ticket.find(params[:id])
@ticket.attributes = params[:ticket]
-
+
@ticket.comments.last.posted_by = (current_user ? current_user.id : nil) #protecting posted_by isn't working, so this should protect it.
if @ticket.save
@@ -60,7 +60,7 @@ class TicketsController < ApplicationController
end
private
-
+
# not using now, as we are using comment_attributes= from the Ticket model
=begin
def add_comment
diff --git a/help/test/functional/tickets_controller_test.rb b/help/test/functional/tickets_controller_test.rb
index 6bdb6c7..b9e03ac 100644
--- a/help/test/functional/tickets_controller_test.rb
+++ b/help/test/functional/tickets_controller_test.rb
@@ -35,7 +35,7 @@ class TicketsControllerTest < ActionController::TestCase
params = {:title => "ticket test title", :comments_attributes => {"0" => {"body" =>"body of test ticket"}}}
- login User.last
+ login :email => "test@email.net"
assert_difference('Ticket.count') do
post :create, :ticket => params
diff --git a/users/test/support/stub_record_helper.rb b/users/test/support/stub_record_helper.rb
index e744ad7..ede21cf 100644
--- a/users/test/support/stub_record_helper.rb
+++ b/users/test/support/stub_record_helper.rb
@@ -7,7 +7,7 @@ module StubRecordHelper
params.reverse_merge!(klass.valid_attributes_hash)
end
params[:params] = params.stringify_keys
- params.reverse_merge! :id => 123,
+ params.reverse_merge! :id => "A123",
:class => klass,
:to_key => ['123'],
:to_json => %Q({"stub":"#{klass.name}"}),