module_result_test.rb
1.45 KB
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
require "test_helper"
require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures"
class ModuleResultTest < ActiveSupport::TestCase
def setup
@hash = ModuleResultFixtures.module_result_hash
@module_result = ModuleResultFixtures.module_result
end
should 'create module result' do
assert_equal @hash[:id] , Kalibro::ModuleResult.new(@hash).id
end
should 'convert module result to hash' do
assert_equal @hash, @module_result.to_hash
end
should 'find module result' do
response = {:module_result => @hash}
Kalibro::ModuleResult.expects(:request).with(:get_module_result, {:module_result_id => @module_result.id}).returns(response)
assert_equal @module_result.grade, Kalibro::ModuleResult.find(@module_result.id).grade
end
should 'return children of a module result' do
response = {:module_result => [@hash]}
Kalibro::ModuleResult.expects(:request).with(:children_of, {:module_result_id => @module_result.id}).returns(response)
assert @hash[:id], @module_result.children.first.id
end
should 'return history of a module result' do
Kalibro::ModuleResult.expects(:request).with(:history_of_module, {:module_result_id => @module_result.id}).returns({:date_module_result => [DateModuleResultFixtures.date_module_result_hash]})
assert_equal DateModuleResultFixtures.date_module_result_hash[:module_result][:id], Kalibro::ModuleResult.history_of(@module_result.id).first.module_result.id
end
end