Commit 617e73a64216fe49ba2af40e43d292f9e9098c72
1 parent
66101891
Exists in
gov-user-refactoring-rails4
gov-user: adapt to rails4
Showing
11 changed files
with
12 additions
and
31 deletions
Show diff stats
src/noosfero-spb/gov_user/features/institution_registration.feature
@@ -5,7 +5,7 @@ Feature: Institution Field | @@ -5,7 +5,7 @@ Feature: Institution Field | ||
5 | 5 | ||
6 | Background: | 6 | Background: |
7 | Given plugin GovUser is enabled on environment | 7 | Given plugin GovUser is enabled on environment |
8 | - And I am logged in as mpog_admin | 8 | + And I am logged in as admin |
9 | And Institutions has initial default values on database | 9 | And Institutions has initial default values on database |
10 | 10 | ||
11 | @selenium | 11 | @selenium |
src/noosfero-spb/gov_user/features/step_definitions/gov_user_steps.rb
@@ -69,22 +69,3 @@ end | @@ -69,22 +69,3 @@ end | ||
69 | Given /^I sleep for (\d+) seconds$/ do |time| | 69 | Given /^I sleep for (\d+) seconds$/ do |time| |
70 | sleep time.to_i | 70 | sleep time.to_i |
71 | end | 71 | end |
72 | - | ||
73 | -Given /^I am logged in as mpog_admin$/ do | ||
74 | - visit('/account/logout') | ||
75 | - | ||
76 | - user = User.new(:login => 'admin_user', :password => '123456', :password_confirmation => '123456', :email => 'admin_user@example.com') | ||
77 | - person = Person.new :name=>"Mpog Admin", :identifier=>"mpog-admin" | ||
78 | - user.person = person | ||
79 | - user.save! | ||
80 | - | ||
81 | - user.activate | ||
82 | - e = Environment.default | ||
83 | - e.add_admin(user.person) | ||
84 | - | ||
85 | - visit('/account/login') | ||
86 | - fill_in("Username", :with => user.login) | ||
87 | - fill_in("Password", :with => '123456') | ||
88 | - click_button("Log in") | ||
89 | -end | ||
90 | - |
src/noosfero-spb/gov_user/lib/gov_user_plugin/governmental_power.rb
src/noosfero-spb/gov_user/lib/gov_user_plugin/governmental_sphere.rb
src/noosfero-spb/gov_user/lib/gov_user_plugin/institution.rb
1 | -class GovUserPlugin::Institution < Noosfero::Plugin::ActiveRecord | 1 | +class GovUserPlugin::Institution < ActiveRecord::Base |
2 | has_many :comments | 2 | has_many :comments |
3 | 3 | ||
4 | SEARCH_FILTERS = { | 4 | SEARCH_FILTERS = { |
@@ -28,8 +28,8 @@ class GovUserPlugin::Institution < Noosfero::Plugin::ActiveRecord | @@ -28,8 +28,8 @@ class GovUserPlugin::Institution < Noosfero::Plugin::ActiveRecord | ||
28 | 28 | ||
29 | belongs_to :community | 29 | belongs_to :community |
30 | 30 | ||
31 | - scope :public, :conditions => { :type => "GovUserPlugin::PublicInstitution" } | ||
32 | - scope :private, :conditions => { :type => "GovUserPlugin::PrivateInstitution" } | 31 | + scope :is_public, :conditions => { :type => "GovUserPlugin::PublicInstitution" } |
32 | + scope :is_private, :conditions => { :type => "GovUserPlugin::PrivateInstitution" } | ||
33 | scope :search_institution, lambda{ |value| | 33 | scope :search_institution, lambda{ |value| |
34 | where("name ilike ? OR acronym ilike ?", "%#{value}%", "%#{value}%" ) | 34 | where("name ilike ? OR acronym ilike ?", "%#{value}%", "%#{value}%" ) |
35 | } | 35 | } |
src/noosfero-spb/gov_user/lib/gov_user_plugin/institutions_organization_ratings.rb
1 | -class GovUserPlugin::InstitutionsOrganizationRatings < Noosfero::Plugin::ActiveRecord | 1 | +class GovUserPlugin::InstitutionsOrganizationRatings < ActiveRecord::Base |
2 | self.primary_key = :institution_id | 2 | self.primary_key = :institution_id |
3 | 3 | ||
4 | attr_accessible :institution, :organization_rating | 4 | attr_accessible :institution, :organization_rating |
src/noosfero-spb/gov_user/lib/gov_user_plugin/institutions_users.rb
1 | -class GovUserPlugin::InstitutionsUsers < Noosfero::Plugin::ActiveRecord | 1 | +class GovUserPlugin::InstitutionsUsers < ActiveRecord::Base |
2 | belongs_to :user | 2 | belongs_to :user |
3 | belongs_to :institution, :class_name => 'GovUserPlugin::Institution' | 3 | belongs_to :institution, :class_name => 'GovUserPlugin::Institution' |
4 | end | 4 | end |
src/noosfero-spb/gov_user/lib/gov_user_plugin/juridical_nature.rb
src/noosfero-spb/gov_user/lib/gov_user_plugin/public_institution.rb
@@ -7,7 +7,7 @@ class GovUserPlugin::PublicInstitution < GovUserPlugin::Institution | @@ -7,7 +7,7 @@ class GovUserPlugin::PublicInstitution < GovUserPlugin::Institution | ||
7 | 7 | ||
8 | validates_format_of( | 8 | validates_format_of( |
9 | :cnpj, | 9 | :cnpj, |
10 | - :with => /^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/, | 10 | + :with => /\A\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}\z/, |
11 | :allow_nil => true, :allow_blank => true | 11 | :allow_nil => true, :allow_blank => true |
12 | ) | 12 | ) |
13 | end | 13 | end |
src/noosfero-spb/gov_user/test/unit/gov_user_plugin/governmental_power_test.rb
@@ -28,6 +28,6 @@ class GovUserPlugin::GovernmentalPowerTest < ActiveSupport::TestCase | @@ -28,6 +28,6 @@ class GovUserPlugin::GovernmentalPowerTest < ActiveSupport::TestCase | ||
28 | inst_cnpj | 28 | inst_cnpj |
29 | ) | 29 | ) |
30 | 30 | ||
31 | - assert_equal gov_power.institutions.public.count, GovUserPlugin::PublicInstitution.count | 31 | + assert_equal gov_power.institutions.is_public.count, GovUserPlugin::PublicInstitution.count |
32 | end | 32 | end |
33 | end | 33 | end |
src/noosfero-spb/gov_user/test/unit/gov_user_plugin/juridical_nature_test.rb
@@ -18,6 +18,6 @@ class GovUserPlugin::JuridicalNatureTest < ActiveSupport::TestCase | @@ -18,6 +18,6 @@ class GovUserPlugin::JuridicalNatureTest < ActiveSupport::TestCase | ||
18 | juridical_nature = GovUserPlugin::JuridicalNature.create(:name => "Autarquia") | 18 | juridical_nature = GovUserPlugin::JuridicalNature.create(:name => "Autarquia") |
19 | create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", juridical_nature, @govPower, @govSphere, "22.333.444/5555-66") | 19 | create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", juridical_nature, @govPower, @govSphere, "22.333.444/5555-66") |
20 | create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", juridical_nature, @govPower, @govSphere, "22.333.444/5555-77") | 20 | create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", juridical_nature, @govPower, @govSphere, "22.333.444/5555-77") |
21 | - assert juridical_nature.institutions.public.count == GovUserPlugin::PublicInstitution.count | 21 | + assert juridical_nature.institutions.is_public.count == GovUserPlugin::PublicInstitution.count |
22 | end | 22 | end |
23 | end | 23 | end |