From 80516055f3996901804be7e579da5193d6312abc Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Fri, 10 Aug 2007 20:35:52 +0000 Subject: [PATCH] ActionItem11: some tests added to the profile and the enterprise controller --- app/controllers/manage_tags_controller.rb | 2 -- app/views/enterprise/_form.rhtml | 2 +- app/views/enterprise/search.rhtml | 3 +++ config/environment.rb | 1 + lib/extended_tag.rb | 1 - test/fixtures/profiles.yml | 1 + test/functional/enterprise_controller_test.rb | 1 + test/unit/profile_test.rb | 13 +++++++++++++ 8 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 app/views/enterprise/search.rhtml diff --git a/app/controllers/manage_tags_controller.rb b/app/controllers/manage_tags_controller.rb index a27eb65..1a4aa29 100644 --- a/app/controllers/manage_tags_controller.rb +++ b/app/controllers/manage_tags_controller.rb @@ -1,5 +1,3 @@ -require 'extended_tag.rb' - # Manage tags stored by the acts-as_taggable_on_steroids plugin by providing an interface to create, destroy, update and list them class ManageTagsController < ApplicationController diff --git a/app/views/enterprise/_form.rhtml b/app/views/enterprise/_form.rhtml index 2a90dda..c435e07 100644 --- a/app/views/enterprise/_form.rhtml +++ b/app/views/enterprise/_form.rhtml @@ -26,7 +26,7 @@ <%= text_area 'organization_info', 'management_information', 'cols' => 40, 'rows' => 20 %>


-<%= select 'validation_entity', 'id', @validation_entities.map{|v| [v.name, v.id] } %>

+<%= select 'validation_entity', 'id', @validation_entities.map{|v| [v.name, v.id]}, :include_blank => true %>


<%= text_field 'enterprise', 'tag_list', 'size' => 20 %>

diff --git a/app/views/enterprise/search.rhtml b/app/views/enterprise/search.rhtml new file mode 100644 index 0000000..10bd8bc --- /dev/null +++ b/app/views/enterprise/search.rhtml @@ -0,0 +1,3 @@ +

<%= @tagged_enterprises.size.to_s + _(' tags found') %>

+ +<%= render :partial => 'enterprise', :collection => @tagged_enterprises %> diff --git a/config/environment.rb b/config/environment.rb index 0a6d1ae..4530deb 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -53,6 +53,7 @@ end # Include your application configuration below require 'gettext/rails' +require 'extended_tag' Tag.hierarchical = true Comatose.configure do |config| diff --git a/lib/extended_tag.rb b/lib/extended_tag.rb index 8078135..f97cbd7 100644 --- a/lib/extended_tag.rb +++ b/lib/extended_tag.rb @@ -15,7 +15,6 @@ class Tag acts_as_ferret :fields => [:name] - # Return all the tags that were suggested but not yet approved def self.find_pendings self.find_with_pendings(:all, :conditions => ['pending = ?', true]) diff --git a/test/fixtures/profiles.yml b/test/fixtures/profiles.yml index ca38ee3..72204c8 100644 --- a/test/fixtures/profiles.yml +++ b/test/fixtures/profiles.yml @@ -47,3 +47,4 @@ colivre: flexible_template_template: 'default' flexible_template_icon_theme: 'default' flexible_template_theme: 'default' + diff --git a/test/functional/enterprise_controller_test.rb b/test/functional/enterprise_controller_test.rb index b471a2f..45147da 100644 --- a/test/functional/enterprise_controller_test.rb +++ b/test/functional/enterprise_controller_test.rb @@ -17,6 +17,7 @@ class EnterpriseControllerTest < Test::Unit::TestCase login_as 'ze' get :index assert_response :redirect + assert_redirected_to :action => 'show' assert_kind_of Array, assigns(:my_pending_enterprises) end diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index a3b5b04..8e0d576 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -63,4 +63,17 @@ class ProfileTest < Test::Unit::TestCase assert !p.errors.invalid?(:name) end + def test_can_be_tagged + p = Profile.create(:name => 'tagged_profile', :identifier => 'tagged') + p.tags << Tag.create(:name => 'a_tag') + assert Profile.find_tagged_with('a_tag').include?(p) + end + + def test_can_have_affiliated_people + pr = Profile.create(:name => 'composite_profile', :identifier => 'composite') + pe = User.create(:login => 'aff', :email => 'aff@pr.coop', :password => 'blih', :password_confirmation => 'blih').person + pr.people << pe + + assert pe.profiles.include?(pr) + end end -- libgit2 0.21.2