Commit 75de40246eafd1596c168ee050c8e35b33aa7602
1 parent
aa0b1b8b
Exists in
gov-user-refactoring-rails4
gov-user: remove institution? from profile extension
Showing
4 changed files
with
35 additions
and
10 deletions
Show diff stats
src/noosfero-spb/gov_user/lib/ext/community.rb
src/noosfero-spb/gov_user/lib/ext/person.rb
src/noosfero-spb/gov_user/lib/gov_user_plugin.rb
... | ... | @@ -17,6 +17,10 @@ class GovUserPlugin < Noosfero::Plugin |
17 | 17 | _("Add features related to Brazilian government.") |
18 | 18 | end |
19 | 19 | |
20 | + def self.institution?(community) | |
21 | + GovUserPlugin::Institution.where(:community_id => community.id).present? | |
22 | + end | |
23 | + | |
20 | 24 | def stylesheet? |
21 | 25 | true |
22 | 26 | end |
... | ... | @@ -74,12 +78,12 @@ class GovUserPlugin < Noosfero::Plugin |
74 | 78 | |
75 | 79 | def profile_tabs |
76 | 80 | if context.profile.community? |
77 | - return profile_tabs_institution if context.profile.institution? | |
81 | + return profile_tabs_institution if GovUserPlugin.institution?(context.profile) | |
78 | 82 | end |
79 | 83 | end |
80 | 84 | |
81 | 85 | def control_panel_buttons |
82 | - if context.profile.institution? | |
86 | + if GovUserPlugin.institution?(context.profile) | |
83 | 87 | return institution_info_button |
84 | 88 | end |
85 | 89 | 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 | ... | ... |