Commit 1123dc7eaca451e2083c947347c19aeee5d423b2
1 parent
ec4e2491
Exists in
master
and in
29 other branches
ActionItem14: merging offline work. All commit messages com svk below for
reference from the respective action items. r734@cabula: terceiro | 2007-10-17 17:51:40 +0000 ActionItem85: commenting references to unexisting files r735@cabula: terceiro | 2007-10-17 21:13:16 +0000 ActionItem14: adding field names for translation r736@cabula: terceiro | 2007-10-17 21:16:52 +0000 ActionItem14: adding skeleton files for ValidationInfo model r737@cabula: terceiro | 2007-10-17 21:19:52 +0000 ActionItem85: not sure that this Validator class will be useful at all. It also hash a pretty ambiguous name now that we are using the concept of "validator organizations". r738@cabula: terceiro | 2007-10-17 22:02:12 +0000 ActionItem14: implementing ValidationInfo model r739@cabula: terceiro | 2007-10-17 22:25:25 +0000 ActionItem14: checkpoint r740@cabula: terceiro | 2007-10-17 22:32:39 +0000 ActionItem14: adding validation data to database population script r741@cabula: terceiro | 2007-10-17 22:41:25 +0000 ActionItem14: adding validation_methodology r742@cabula: terceiro | 2007-10-17 23:05:05 +0000 ActionItem14: returning a nice (?) 'not informed' instead of nil when there is no data r743@cabula: terceiro | 2007-10-17 23:09:49 +0000 ActionItem14: presenting validation info on validator selection screen r744@cabula: terceiro | 2007-10-18 00:40:19 +0000 ActionItem14: wrote integration test for the enterprise registration process. Still missing: assing tests for the rest of the process (steps done one of the users of the validator organization) git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@721 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
12 changed files
with
185 additions
and
25 deletions
Show diff stats
app/models/create_enterprise.rb
1 | 1 | class CreateEnterprise < Task |
2 | 2 | |
3 | + N_('CreateEnterprise|Identifier') | |
4 | + N_('CreateEnterprise|Name') | |
5 | + N_('CreateEnterprise|Address') | |
6 | + N_('CreateEnterprise|Contact phone') | |
7 | + N_('CreateEnterprise|Contact person') | |
8 | + N_('CreateEnterprise|Acronym') | |
9 | + N_('CreateEnterprise|Foundation year') | |
10 | + N_('CreateEnterprise|Legal form') | |
11 | + N_('CreateEnterprise|Economic activity') | |
12 | + N_('CreateEnterprise|Management information') | |
13 | + | |
3 | 14 | DATA_FIELDS = %w[ name identifier address contact_phone contact_person acronym foundation_year legal_form economic_activity management_information region_id ] |
4 | 15 | |
5 | 16 | serialize :data, Hash | ... | ... |
app/models/organization.rb
1 | 1 | # Represents any organization of the system and has an organization_info object to hold its info |
2 | 2 | class Organization < Profile |
3 | 3 | has_one :organization_info |
4 | - has_many :validated_enterprises, :class_name => 'enterprise' | |
5 | 4 | |
6 | 5 | belongs_to :region |
7 | 6 | |
8 | -# def info | |
9 | -# organization_info | |
10 | -# end | |
7 | + has_one :validation_info | |
11 | 8 | |
12 | -# def info=(infos) | |
13 | -# organization_info.update_attributes(infos) | |
14 | -# end | |
9 | + def validation_methodology | |
10 | + methodology = self.validation_info ? self.validation_info.validation_methodology : nil | |
11 | + methodology || ('<em>' + _('(not informed)') + '</em>') | |
12 | + end | |
13 | + | |
14 | + def validation_restrictions | |
15 | + restrictions = self.validation_info ? self.validation_info.restrictions : nil | |
16 | + restrictions || ('<em>' + _('(not informed)') + '</em>') | |
17 | + end | |
15 | 18 | end | ... | ... |
app/models/validator.rb
app/views/enterprise_registration/select_validator.rhtml
... | ... | @@ -11,6 +11,9 @@ |
11 | 11 | <div> |
12 | 12 | <%= radio_button_tag('create_enterprise[target_id]', validator.id) %> |
13 | 13 | <%= validator.name %> |
14 | + | |
15 | + <%= labelled_form_field(_('Validation Methodology:'), validator.validation_methodology) %> | |
16 | + <%= labelled_form_field(_('Restrictions (if any):'), validator.validation_restrictions) %> | |
14 | 17 | </div> |
15 | 18 | <% end %> |
16 | 19 | ... | ... |
app/views/layouts/application.rhtml
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <%= javascript_include_tag 'prototype' %> |
6 | 6 | <%# javascript_include_tag 'sweetTitles' %> |
7 | 7 | <%= javascript_include_tag 'tiny_mce/tiny_mce.js' %> |
8 | - <%= javascript_include_tag 'scriptaculous' %> | |
8 | + <%# javascript_include_tag 'scriptaculous' %> | |
9 | 9 | <%= javascript_include_tag 'dragdrop' %> |
10 | 10 | <%= javascript_include_tag 'effects' %> |
11 | 11 | <%= javascript_include_tag 'noosfero_tiny_mce.js' %> | ... | ... |
... | ... | @@ -0,0 +1,15 @@ |
1 | +class CreateValidationInfos < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + create_table :validation_infos do |t| | |
4 | + t.column :validation_methodology, :text | |
5 | + t.column :restrictions, :text | |
6 | + | |
7 | + # foreign keys | |
8 | + t.column :organization_id, :integer | |
9 | + end | |
10 | + end | |
11 | + | |
12 | + def self.down | |
13 | + drop_table :validation_infos | |
14 | + end | |
15 | +end | ... | ... |
public/stylesheets/menu.css
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | #accessibility_menu a { |
23 | 23 | padding-left: 9px; |
24 | 24 | margin-left: 5px; |
25 | - background: url("../images/ico_enterlink.gif"); | |
25 | + /* background: url("../images/ico_enterlink.gif"); */ | |
26 | 26 | background-repeat: no-repeat; |
27 | 27 | background-position: 0px 6px; |
28 | 28 | color: #dfdfdf; | ... | ... |
script/anhetegua
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | require File.dirname(__FILE__) + '/../config/environment' |
3 | 3 | |
4 | 4 | Environment.default.categories.destroy_all |
5 | +Organization.destroy_all | |
5 | 6 | |
6 | 7 | def new_category(parent, name, color = nil) |
7 | 8 | category = Environment.default.categories.build(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil)) |
... | ... | @@ -15,6 +16,14 @@ def new_region(parent, name, color = nil) |
15 | 16 | region |
16 | 17 | end |
17 | 18 | |
19 | +def new_validator(region, name, identifier) | |
20 | + org = Organization.new(:name => name, :identifier => identifier) | |
21 | + org.validation_info = ValidationInfo.new(:validation_methodology => 'some methodology we don\'t care about') | |
22 | + org.save! | |
23 | + region.validators << org | |
24 | + org | |
25 | +end | |
26 | + | |
18 | 27 | tematicas = new_category(nil, 'Temáticas', 1) |
19 | 28 | new_category(tematicas, 'Finanças Solidárias') |
20 | 29 | new_category(tematicas, 'Marco Legal') |
... | ... | @@ -29,14 +38,13 @@ cadeias = new_category(nil, 'Cadeias', 3) |
29 | 38 | new_category(cadeias, 'Algodão') |
30 | 39 | new_category(cadeias, 'Tecnologia de Informação') |
31 | 40 | |
32 | - | |
33 | 41 | # validators |
34 | -ba.validators << Organization.create!(:name => "Colivre", :identifier => 'colivre') | |
35 | -ba.validators << Organization.create!(:name => "Forum Baiano de Economia Solidaraia", :identifier => 'ecosolbahia') | |
42 | +new_validator(ba, "Colivre", 'colivre') | |
43 | +new_validator(ba, "Forum Baiano de Economia Solidaraia", 'ecosolbahia') | |
36 | 44 | |
37 | -df.validators << Organization.create!(:name => 'Caritas', :identifier => 'caritas') | |
38 | -df.validators << Organization.create!(:name => 'Forum Brasileiro de Economia Solidaria', :identifier => 'fbes') | |
45 | +new_validator(df, 'Caritas', 'caritas') | |
46 | +new_validator(df, 'Forum Brasileiro de Economia Solidaria', 'fbes') | |
39 | 47 | |
40 | -rs.validators << Organization.create!(:name => 'Associacao Software Livre.Org', :identifier => 'asl') | |
41 | -rs.validators << Organization.create!(:name => 'Forum Gaucho de Economia Solidaria', :identifier => 'ecosolrs') | |
48 | +new_validator(rs, 'Associacao Software Livre.Org', 'asl') | |
49 | +new_validator(rs, 'Forum Gaucho de Economia Solidaria', 'ecosolrs') | |
42 | 50 | ... | ... |
... | ... | @@ -0,0 +1,51 @@ |
1 | +require "#{File.dirname(__FILE__)}/../test_helper" | |
2 | + | |
3 | +class EnterpriseRegistrationTest < ActionController::IntegrationTest | |
4 | + | |
5 | + fixtures :users, :profiles, :environments | |
6 | + | |
7 | + # Replace this with your real tests. | |
8 | + should 'be able to create an enterprise registration request' do | |
9 | + | |
10 | + environment = Environment.default | |
11 | + region1 = environment.regions.build(:name => 'A region') | |
12 | + region1.save! | |
13 | + region2 = environment.regions.build(:name => 'Other region') | |
14 | + region2.save! | |
15 | + org = Organization.create!(:name => "My organization", :identifier => 'myorg') | |
16 | + region1.validators << org | |
17 | + | |
18 | + login('ze', 'test') | |
19 | + | |
20 | + get '/enterprise_registration' | |
21 | + assert_response :success | |
22 | + assert_tag :tag => 'form', :attributes => { :action => '/enterprise_registration', :method => 'post' }, :descendant => { :tag => 'input', :attributes => { :type => 'text', :name => 'create_enterprise[identifier]'} } | |
23 | + | |
24 | + data = { | |
25 | + :name => 'My new enterprise', | |
26 | + :identifier => 'mynewenterprise', | |
27 | + :address => 'satan street, 666', | |
28 | + :contact_phone => '1298372198', | |
29 | + :contact_person => 'random joe', | |
30 | + :legal_form => 'cooperative', | |
31 | + :economic_activity => 'free software', | |
32 | + :region_id => region1.id, | |
33 | + } | |
34 | + | |
35 | + post '/enterprise_registration', :create_enterprise => data | |
36 | + assert_response :success | |
37 | + assert_tag :tag => 'form', :attributes => { :action => '/enterprise_registration', :method => 'post' }, :descendant => { :tag => 'input', :attributes => { :type => 'radio', :name => 'create_enterprise[target_id]', :value => org.id } } | |
38 | + | |
39 | + assert_difference CreateEnterprise, :count do | |
40 | + post '/enterprise_registration', :create_enterprise => data.merge(:target_id => org.id) | |
41 | + end | |
42 | + | |
43 | + assert_tag :tag => 'a', :attributes => { :href => '/' } | |
44 | + | |
45 | + # FIXME: add here | |
46 | + # - the steps carried on by the validator organization to approve the registration | |
47 | + # - the steps carried on by the requestor after that | |
48 | + | |
49 | + end | |
50 | + | |
51 | +end | ... | ... |
test/unit/organization_test.rb
... | ... | @@ -3,8 +3,54 @@ require File.dirname(__FILE__) + '/../test_helper' |
3 | 3 | class OrganizationTest < Test::Unit::TestCase |
4 | 4 | fixtures :profiles |
5 | 5 | |
6 | - # FIXME: add actual organization tests here | |
7 | - def test_truth | |
8 | - assert_not_nil Organization.new | |
6 | + should 'reference organization info' do | |
7 | + org = Organization.new | |
8 | + assert_raise ActiveRecord::AssociationTypeMismatch do | |
9 | + org.organization_info = 1 | |
10 | + end | |
11 | + assert_nothing_raised do | |
12 | + org.organization_info = OrganizationInfo.new | |
13 | + end | |
9 | 14 | end |
15 | + | |
16 | + should 'reference region' do | |
17 | + org = Organization.new | |
18 | + assert_raise ActiveRecord::AssociationTypeMismatch do | |
19 | + org.region = 1 | |
20 | + end | |
21 | + assert_nothing_raised do | |
22 | + org.region = Region.new | |
23 | + end | |
24 | + end | |
25 | + | |
26 | + should 'reference validation info' do | |
27 | + org = Organization.new | |
28 | + assert_raise ActiveRecord::AssociationTypeMismatch do | |
29 | + org.validation_info = 1 | |
30 | + end | |
31 | + assert_nothing_raised do | |
32 | + org.validation_info = ValidationInfo.new | |
33 | + end | |
34 | + end | |
35 | + | |
36 | + should 'provide validation methodology' do | |
37 | + org = Organization.new | |
38 | + assert_equal '<em>(not informed)</em>', org.validation_methodology | |
39 | + | |
40 | + info = ValidationInfo.new | |
41 | + info.expects(:validation_methodology).returns('something') | |
42 | + org.validation_info = info | |
43 | + assert_equal 'something', org.validation_methodology | |
44 | + end | |
45 | + | |
46 | + should 'provide validation restrictions' do | |
47 | + org = Organization.new | |
48 | + assert_equal '<em>(not informed)</em>', org.validation_restrictions | |
49 | + | |
50 | + info = ValidationInfo.new | |
51 | + info.expects(:restrictions).returns('something') | |
52 | + org.validation_info = info | |
53 | + assert_equal 'something', org.validation_restrictions | |
54 | + end | |
55 | + | |
10 | 56 | end | ... | ... |
... | ... | @@ -0,0 +1,24 @@ |
1 | +require File.dirname(__FILE__) + '/../test_helper' | |
2 | + | |
3 | +class ValidationInfoTest < Test::Unit::TestCase | |
4 | + | |
5 | + should 'validate the presence of validation methodology description' do | |
6 | + info = ValidationInfo.new | |
7 | + info.valid? | |
8 | + assert info.errors.invalid?(:validation_methodology) | |
9 | + info.validation_methodology = 'lalala' | |
10 | + info.valid? | |
11 | + assert !info.errors.invalid?(:validation_methodology) | |
12 | + end | |
13 | + | |
14 | + should 'refer to and validate the presence of an organization' do | |
15 | + info = ValidationInfo.new | |
16 | + assert_raise ActiveRecord::AssociationTypeMismatch do | |
17 | + info.organization = 1 | |
18 | + end | |
19 | + assert_nothing_raised do | |
20 | + info.organization = Organization.new | |
21 | + end | |
22 | + end | |
23 | + | |
24 | +end | ... | ... |