Commit 6dfb97e5ce2c75c5c34698f31c4e2064adfc9ee9
Committed by
Marcos Pereira
1 parent
2cd18c7c
Exists in
gov-user-to-organization
and in
1 other branch
gov-user: remove institution? from profile extension
Showing
3 changed files
with
35 additions
and
6 deletions
Show diff stats
src/noosfero-spb/gov_user/lib/ext/community.rb
src/noosfero-spb/gov_user/lib/gov_user_plugin.rb
... | ... | @@ -21,6 +21,10 @@ class GovUserPlugin < Noosfero::Plugin |
21 | 21 | _("Add features related to Brazilian government.") |
22 | 22 | end |
23 | 23 | |
24 | + def self.institution?(community) | |
25 | + GovUserPlugin::Institution.where(:community_id => community.id).present? | |
26 | + end | |
27 | + | |
24 | 28 | def stylesheet? |
25 | 29 | true |
26 | 30 | end |
... | ... | @@ -76,12 +80,12 @@ class GovUserPlugin < Noosfero::Plugin |
76 | 80 | |
77 | 81 | def profile_tabs |
78 | 82 | if context.profile.community? |
79 | - return profile_tabs_institution if context.profile.institution? | |
83 | + return profile_tabs_institution if GovUserPlugin.institution?(context.profile) | |
80 | 84 | end |
81 | 85 | end |
82 | 86 | |
83 | 87 | def control_panel_buttons |
84 | - if context.profile.institution? | |
88 | + if GovUserPlugin.institution?(context.profile) | |
85 | 89 | return institution_info_button |
86 | 90 | end |
87 | 91 | end | ... | ... |
src/noosfero-spb/gov_user/test/unit/gov_user_plugin_test.rb
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | |
3 | + | |
4 | +class GovUserPluginTest < ActiveSupport::TestCase | |
5 | + include PluginTestHelper | |
6 | + | |
7 | + def setup | |
8 | + @gov_power = GovUserPlugin::GovernmentalPower.create(:name=>"Some Gov Power") | |
9 | + @gov_sphere = GovUserPlugin::GovernmentalSphere.create(:name=>"Some Gov Sphere") | |
10 | + @juridical_nature = GovUserPlugin::JuridicalNature.create(:name => "Autarquia") | |
11 | + | |
12 | + @institution = create_public_institution( | |
13 | + "Ministerio Publico da Uniao", | |
14 | + "MPU", | |
15 | + "BR", | |
16 | + "DF", | |
17 | + "Gama", | |
18 | + @juridical_nature, | |
19 | + @gov_power, | |
20 | + @gov_sphere, | |
21 | + "11.222.333/4444-55" | |
22 | + ) | |
23 | + end | |
24 | + | |
25 | + should 'check if profile is an institution' do | |
26 | + assert GovUserPlugin.institution?(@institution.community) | |
27 | + assert !GovUserPlugin.institution?(fast_create(Community)) | |
28 | + end | |
29 | +end | ... | ... |