Commit 4b037dacd7fc48bf62b07df7753cead1a0aaf23b
1 parent
41083625
Exists in
software_as_organization
Fix software_info functional tests
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
Showing
2 changed files
with
31 additions
and
33 deletions
Show diff stats
src/noosfero-spb/software_communities/test/functional/profile_controller_test.rb
1 | -require "test_helper" | |
1 | +require 'test_helper' | |
2 | 2 | require 'profile_controller' |
3 | +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | |
3 | 4 | |
4 | 5 | # Re-raise errors caught by the controller. |
5 | 6 | class ProfileController; def rescue_action(e) raise e end; end |
6 | 7 | |
7 | 8 | class ProfileControllerTest < ActionController::TestCase |
9 | + include PluginTestHelper | |
10 | + | |
8 | 11 | def setup |
9 | 12 | Environment.default.enable('products_for_enterprises') |
10 | 13 | @profile = create_user('testuser').person |
... | ... | @@ -14,27 +17,28 @@ class ProfileControllerTest < ActionController::TestCase |
14 | 17 | should 'not count a visit twice for the same user' do |
15 | 18 | profile = create_user('someone').person |
16 | 19 | login_as(@profile.identifier) |
17 | - community = fast_create('Community') | |
20 | + software = create_software_info("a software").software | |
18 | 21 | |
19 | - get :index, :profile => community.identifier | |
20 | - community.reload | |
21 | - assert_equal 1, community.hits | |
22 | + get :index, :profile => software.identifier | |
23 | + software.reload | |
24 | + assert_equal 1, software.hits | |
22 | 25 | |
23 | - get :index, :profile => community.identifier | |
24 | - community.reload | |
25 | - assert_equal 1, community.hits | |
26 | + get :index, :profile => software.identifier | |
27 | + software.reload | |
28 | + assert_equal 1, software.hits | |
26 | 29 | end |
27 | 30 | |
28 | 31 | should 'not count a visit twice for unlogged users' do |
29 | 32 | profile = create_user('someone').person |
30 | - community = fast_create('Community') | |
31 | - get :index, :profile => community.identifier | |
32 | - community.reload | |
33 | - assert_equal 1, community.hits | |
34 | - | |
35 | - get :index, :profile => community.identifier | |
36 | - community.reload | |
37 | - assert_equal 1, community.hits | |
33 | + software = create_software_info("a software").software | |
34 | + | |
35 | + get :index, :profile => software.identifier | |
36 | + software.reload | |
37 | + assert_equal 1, software.hits | |
38 | + | |
39 | + get :index, :profile => software.identifier | |
40 | + software.reload | |
41 | + assert_equal 1, software.hits | |
38 | 42 | end |
39 | 43 | end |
40 | 44 | ... | ... |
src/noosfero-spb/software_communities/test/functional/profile_editor_controller_test.rb
... | ... | @@ -29,15 +29,6 @@ class ProfileEditorControllerTest < ActionController::TestCase |
29 | 29 | @environment.save |
30 | 30 | end |
31 | 31 | |
32 | - should "redirect to edit_software_community on edit community of software" do | |
33 | - software = create_software_info("Test Software") | |
34 | - | |
35 | - post :edit, :profile => software.community.identifier | |
36 | - | |
37 | - assert_redirected_to :controller => 'profile_editor', :action => 'edit_software_community' | |
38 | - end | |
39 | - | |
40 | - | |
41 | 32 | protected |
42 | 33 | |
43 | 34 | def create_basic_user |
... | ... | @@ -49,21 +40,24 @@ class ProfileEditorControllerTest < ActionController::TestCase |
49 | 40 | user |
50 | 41 | end |
51 | 42 | |
52 | - def create_community name | |
53 | - community = fast_create(Community) | |
54 | - community.name = name | |
55 | - community.save | |
56 | - community | |
43 | + def create_software name | |
44 | + software = Software.new | |
45 | + software.name = name | |
46 | + software.identifier = name.to_slug | |
47 | + software | |
57 | 48 | end |
58 | 49 | |
59 | 50 | def create_software_info name, finality = "something", acronym = "" |
60 | - community = create_community(name) | |
51 | + software = create_software(name) | |
61 | 52 | software_info = SoftwareInfo.new |
62 | - software_info.community = community | |
53 | + software_info.software = software | |
63 | 54 | software_info.finality = finality |
64 | 55 | software_info.acronym = acronym |
65 | 56 | software_info.public_software = true |
66 | - software_info.save | |
57 | + | |
58 | + software.software_info = software_info | |
59 | + software.save! | |
60 | + | |
67 | 61 | software_info |
68 | 62 | end |
69 | 63 | ... | ... |