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 | require 'profile_controller' | 2 | require 'profile_controller' |
| 3 | +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | ||
| 3 | 4 | ||
| 4 | # Re-raise errors caught by the controller. | 5 | # Re-raise errors caught by the controller. |
| 5 | class ProfileController; def rescue_action(e) raise e end; end | 6 | class ProfileController; def rescue_action(e) raise e end; end |
| 6 | 7 | ||
| 7 | class ProfileControllerTest < ActionController::TestCase | 8 | class ProfileControllerTest < ActionController::TestCase |
| 9 | + include PluginTestHelper | ||
| 10 | + | ||
| 8 | def setup | 11 | def setup |
| 9 | Environment.default.enable('products_for_enterprises') | 12 | Environment.default.enable('products_for_enterprises') |
| 10 | @profile = create_user('testuser').person | 13 | @profile = create_user('testuser').person |
| @@ -14,27 +17,28 @@ class ProfileControllerTest < ActionController::TestCase | @@ -14,27 +17,28 @@ class ProfileControllerTest < ActionController::TestCase | ||
| 14 | should 'not count a visit twice for the same user' do | 17 | should 'not count a visit twice for the same user' do |
| 15 | profile = create_user('someone').person | 18 | profile = create_user('someone').person |
| 16 | login_as(@profile.identifier) | 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 | end | 29 | end |
| 27 | 30 | ||
| 28 | should 'not count a visit twice for unlogged users' do | 31 | should 'not count a visit twice for unlogged users' do |
| 29 | profile = create_user('someone').person | 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 | end | 42 | end |
| 39 | end | 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,15 +29,6 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
| 29 | @environment.save | 29 | @environment.save |
| 30 | end | 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 | protected | 32 | protected |
| 42 | 33 | ||
| 43 | def create_basic_user | 34 | def create_basic_user |
| @@ -49,21 +40,24 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -49,21 +40,24 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
| 49 | user | 40 | user |
| 50 | end | 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 | end | 48 | end |
| 58 | 49 | ||
| 59 | def create_software_info name, finality = "something", acronym = "" | 50 | def create_software_info name, finality = "something", acronym = "" |
| 60 | - community = create_community(name) | 51 | + software = create_software(name) |
| 61 | software_info = SoftwareInfo.new | 52 | software_info = SoftwareInfo.new |
| 62 | - software_info.community = community | 53 | + software_info.software = software |
| 63 | software_info.finality = finality | 54 | software_info.finality = finality |
| 64 | software_info.acronym = acronym | 55 | software_info.acronym = acronym |
| 65 | software_info.public_software = true | 56 | software_info.public_software = true |
| 66 | - software_info.save | 57 | + |
| 58 | + software.software_info = software_info | ||
| 59 | + software.save! | ||
| 60 | + | ||
| 67 | software_info | 61 | software_info |
| 68 | end | 62 | end |
| 69 | 63 |