My favorites | Sign in
Project Hosting will be READ-ONLY Thursday at 3:00pm UTC for up to 3 hours for network maintenance.
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require 'test_helper'

class TrackControllerTest < ActionController::TestCase
test "report simple" do
send_message 'shopping 20', :sender => 'pepe'
assert_tracked :user => 'pepe', :amount => 20, :reason => 'shopping'
end

test "report other way" do
send_message '20 shopping', :sender => 'pepe'
assert_tracked :user => 'pepe', :amount => 20, :reason => 'shopping'
end

test "report dollar simbol" do
send_message 'shopping $20', :sender => 'pepe'
assert_tracked :user => 'pepe', :amount => 20, :reason => 'shopping'
end

test "report many things" do
send_message '3 beers 20', :sender => 'pepe'
assert_tracked :user => 'pepe', :amount => 20, :reason => '3 beers'
end

test "report and get answer" do
send_message 'shopping $20!', :sender => 'pepe'
assert_tracked :user => 'pepe', :amount => 20, :reason => 'shopping'

assert_header 'X-GeoChat-Action', 'reply'
assert_equal 'shopping: 20.0 unknown currency', @response.body
end

test "report and don't get answer" do
send_message 'shopping $20', :sender => 'pepe'
assert_header 'X-GeoChat-Action', nil
end

test "change currency" do
send_message 'dollars', :sender => 'pepe'
send_message 'shopping 20', :sender => 'pepe'
assert_tracked :user => 'pepe', :amount => 20, :reason => 'shopping', :currency => 'dollars'
end

test "change currency don't get answer" do
send_message 'dollars', :sender => 'pepe'
assert_header 'X-GeoChat-Action', nil
end

test "change currency and get answer" do
send_message 'dollars!', :sender => 'pepe'
assert_header 'X-GeoChat-Action', 'reply'
assert_equal 'Currency changed to dollars', @response.body
end

def send_message(message, options)
@request.env['RAW_POST_DATA'] = message
post :expense, options
end

def assert_tracked(options)
users = User.all
assert_equal 1, users.length
assert_equal options[:user], users[0].name

expenses = Expense.all
assert_equal users[0].id, expenses[0].user_id
assert_equal options[:amount], expenses[0].amount
assert_equal options[:reason], expenses[0].reason
assert_equal options[:currency], expenses[0].currency
end

def assert_header(header, value)
assert_equal @response.headers[header], value
end
end

Change log

8910489f3476 by Ary Borenszweig <aborensz...@manas.com.ar> on Jun 28, 2010   Diff
Added possibility to get a reply from
geochat by appending a ! to the text
message
Go to: 
Project members, sign in to write a code review

Older revisions

f799606748b0 by Ary Borenszweig <aborensz...@manas.com.ar> on Jun 16, 2010   Diff
Added test to change currency
e5cb53176dca by Ary Borenszweig <aborensz...@manas.com.ar> on Jun 16, 2010   Diff
Initial commit
All revisions of this file

File info

Size: 2332 bytes, 74 lines
Powered by Google Project Hosting