Commit 80516055f3996901804be7e579da5193d6312abc

Authored by MoisesMachado
1 parent 1dd1cd53

ActionItem11: some tests added to the profile and the enterprise controller


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@331 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/manage_tags_controller.rb
1   -require 'extended_tag.rb'
2   -
3 1 # Manage tags stored by the acts-as_taggable_on_steroids plugin by providing an interface to create, destroy, update and list them
4 2 class ManageTagsController < ApplicationController
5 3  
... ...
app/views/enterprise/_form.rhtml
... ... @@ -26,7 +26,7 @@
26 26 <%= text_area 'organization_info', 'management_information', 'cols' => 40, 'rows' => 20 %></p>
27 27  
28 28 <p><label for="validation_entity"><%= _('Validation Entity') %></label><br/>
29   -<%= select 'validation_entity', 'id', @validation_entities.map{|v| [v.name, v.id] } %></p>
  29 +<%= select 'validation_entity', 'id', @validation_entities.map{|v| [v.name, v.id]}, :include_blank => true %></p>
30 30  
31 31 <p><label for="tag_list"><%= _('Tags') %></label><br/>
32 32 <%= text_field 'enterprise', 'tag_list', 'size' => 20 %></p>
... ...
app/views/enterprise/search.rhtml 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +<h2> <%= @tagged_enterprises.size.to_s + _(' tags found') %> </h2>
  2 +
  3 +<%= render :partial => 'enterprise', :collection => @tagged_enterprises %>
... ...
config/environment.rb
... ... @@ -53,6 +53,7 @@ end
53 53 # Include your application configuration below
54 54  
55 55 require 'gettext/rails'
  56 +require 'extended_tag'
56 57 Tag.hierarchical = true
57 58  
58 59 Comatose.configure do |config|
... ...
lib/extended_tag.rb
... ... @@ -15,7 +15,6 @@ class Tag
15 15  
16 16 acts_as_ferret :fields => [:name]
17 17  
18   -
19 18 # Return all the tags that were suggested but not yet approved
20 19 def self.find_pendings
21 20 self.find_with_pendings(:all, :conditions => ['pending = ?', true])
... ...
test/fixtures/profiles.yml
... ... @@ -47,3 +47,4 @@ colivre:
47 47 flexible_template_template: 'default'
48 48 flexible_template_icon_theme: 'default'
49 49 flexible_template_theme: 'default'
  50 +
... ...
test/functional/enterprise_controller_test.rb
... ... @@ -17,6 +17,7 @@ class EnterpriseControllerTest &lt; Test::Unit::TestCase
17 17 login_as 'ze'
18 18 get :index
19 19 assert_response :redirect
  20 + assert_redirected_to :action => 'show'
20 21  
21 22 assert_kind_of Array, assigns(:my_pending_enterprises)
22 23 end
... ...
test/unit/profile_test.rb
... ... @@ -63,4 +63,17 @@ class ProfileTest &lt; Test::Unit::TestCase
63 63 assert !p.errors.invalid?(:name)
64 64 end
65 65  
  66 + def test_can_be_tagged
  67 + p = Profile.create(:name => 'tagged_profile', :identifier => 'tagged')
  68 + p.tags << Tag.create(:name => 'a_tag')
  69 + assert Profile.find_tagged_with('a_tag').include?(p)
  70 + end
  71 +
  72 + def test_can_have_affiliated_people
  73 + pr = Profile.create(:name => 'composite_profile', :identifier => 'composite')
  74 + pe = User.create(:login => 'aff', :email => 'aff@pr.coop', :password => 'blih', :password_confirmation => 'blih').person
  75 + pr.people << pe
  76 +
  77 + assert pe.profiles.include?(pr)
  78 + end
66 79 end
... ...