Commit 5ab5223463cf5f2b2b75d62b61e068f13dad05e1
Committed by
David Silva
1 parent
e15e7582
Exists in
master
and in
5 other branches
Add unit tests to methods license_info and another_license of SoftwareInfo
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Showing
2 changed files
with
51 additions
and
0 deletions
Show diff stats
test/helpers/plugin_test_helper.rb
@@ -78,4 +78,11 @@ module PluginTestHelper | @@ -78,4 +78,11 @@ module PluginTestHelper | ||
78 | user | 78 | user |
79 | end | 79 | end |
80 | 80 | ||
81 | + def create_license_info version, link = "" | ||
82 | + license = LicenseInfo.create(:version => version) | ||
83 | + license.link = link | ||
84 | + license.save | ||
85 | + | ||
86 | + license | ||
87 | + end | ||
81 | end | 88 | end |
@@ -0,0 +1,44 @@ | @@ -0,0 +1,44 @@ | ||
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | ||
3 | + | ||
4 | +class SoftwareInfoValidationTest < ActiveSupport::TestCase | ||
5 | + | ||
6 | + include PluginTestHelper | ||
7 | + | ||
8 | + def setup | ||
9 | + @license_another = create_license_info("Another") | ||
10 | + end | ||
11 | + | ||
12 | + should "Return original license_info when license is not 'Another'" do | ||
13 | + @software_info = create_software_info("software_test") | ||
14 | + @license_info = create_license_info("license_test") | ||
15 | + | ||
16 | + @software_info.license_info = @license_info | ||
17 | + | ||
18 | + assert_equal @software_info.license_info, @license_info | ||
19 | + end | ||
20 | + | ||
21 | + should "Return license_info with nil id when license is 'Another'" do | ||
22 | + @software_info = create_software_info("software_test") | ||
23 | + | ||
24 | + @software_info.license_info = @license_another | ||
25 | + | ||
26 | + assert_equal @software_info.license_info_id, @license_another.id | ||
27 | + assert_equal @software_info.license_info.id, nil | ||
28 | + end | ||
29 | + | ||
30 | + should "Return fake license_info when call method another_license" do | ||
31 | + @software_info = create_software_info("software_test") | ||
32 | + | ||
33 | + another_license_version = "Another Version" | ||
34 | + another_license_link = "#another_link" | ||
35 | + | ||
36 | + @software_info.another_license(another_license_version, another_license_link) | ||
37 | + | ||
38 | + assert_equal @software_info.license_info_id, @license_another.id | ||
39 | + assert_equal @software_info.license_info.id, nil | ||
40 | + assert_equal @software_info.license_info.version, another_license_version | ||
41 | + assert_equal @software_info.license_info.link, another_license_link | ||
42 | + end | ||
43 | + | ||
44 | +end | ||
0 | \ No newline at end of file | 45 | \ No newline at end of file |