Commit 661018916ee380d091ae1bc69fc04deb70bf0575
1 parent
1aef0c21
Exists in
gov-user-refactoring-rails4
gov-user: use hotspot to integrate with organization_ratings
Showing
5 changed files
with
21 additions
and
5 deletions
Show diff stats
src/noosfero-spb/gov_user/lib/gov_user_plugin.rb
... | ... | @@ -255,6 +255,11 @@ class GovUserPlugin < Noosfero::Plugin |
255 | 255 | } |
256 | 256 | end |
257 | 257 | |
258 | + def organization_ratings_plugin_rating_created rating, params | |
259 | + institution = GovUserPlugin::Institution.find(params['gov_user_plugin']['institution_id']) | |
260 | + GovUserPlugin::InstitutionsOrganizationRatings.create!(:institution => institution, :organization_rating => rating) | |
261 | + end | |
262 | + | |
258 | 263 | def filter_search_scope(scope, asset) |
259 | 264 | if asset.to_s == 'communities' |
260 | 265 | return [filter_communities(scope), asset] | ... | ... |
src/noosfero-spb/gov_user/lib/gov_user_plugin/institutions_organization_ratings.rb
... | ... | @@ -6,6 +6,9 @@ class GovUserPlugin::InstitutionsOrganizationRatings < Noosfero::Plugin::ActiveR |
6 | 6 | belongs_to :institution, :class_name => 'GovUserPlugin::Institution' |
7 | 7 | belongs_to :organization_rating, :class_name => 'OrganizationRating' |
8 | 8 | |
9 | + validates_presence_of :institution | |
10 | + validates_presence_of :organization_rating | |
11 | + | |
9 | 12 | validate :verify_institution |
10 | 13 | |
11 | 14 | def self.get_institution(rating) | ... | ... |
src/noosfero-spb/gov_user/test/unit/gov_user_plugin/institutions_organization_ratings_test.rb
... | ... | @@ -10,6 +10,18 @@ class GovUserPlugin::InstitutionsOrganizationRatingsTest < ActiveSupport::TestCa |
10 | 10 | @environment.save! |
11 | 11 | end |
12 | 12 | |
13 | + should 'validate presence of institution' do | |
14 | + relation = GovUserPlugin::InstitutionsOrganizationRatings.new | |
15 | + relation.valid? | |
16 | + assert relation.errors[:institution].present? | |
17 | + end | |
18 | + | |
19 | + should 'validate presence of organization_rating' do | |
20 | + relation = GovUserPlugin::InstitutionsOrganizationRatings.new | |
21 | + relation.valid? | |
22 | + assert relation.errors[:organization_rating].present? | |
23 | + end | |
24 | + | |
13 | 25 | should "validate institution if there is an institution_id" do |
14 | 26 | private_institution = build_private_institution "huehue", "hue", "11.222.333/4444-55" |
15 | 27 | relation = GovUserPlugin::InstitutionsOrganizationRatings.new(:institution => private_institution) |
... | ... | @@ -36,4 +48,3 @@ class GovUserPlugin::InstitutionsOrganizationRatingsTest < ActiveSupport::TestCa |
36 | 48 | institution |
37 | 49 | end |
38 | 50 | end |
39 | - | ... | ... |
src/noosfero-spb/gov_user/views/organization_ratings_extra_fields_show_institution.html.erb
src/noosfero-spb/gov_user/views/ratings_extra_field.html.erb
1 | -<% #FIXME Ajust this to work according to InstitutionsOrganizationRatings relation. %> | |
2 | - | |
3 | 1 | <div id="input_institution_comments"> |
4 | 2 | <%= label_tag "input_institution", _("Organization name or Enterprise name")%> |
5 | 3 | <span class="star-tooltip" title="Órgão ou Empresa que você representa e utiliza o software"></span> |
... | ... | @@ -8,5 +6,5 @@ |
8 | 6 | <%= content_tag(:div, _("No institution found"), |
9 | 7 | :id=>"institution_empty_ajax_message", |
10 | 8 | :class=>"errorExplanation hide-field") %> |
11 | - <%= hidden_field_tag "organization_rating[institution_id]", "", id: "institution_selected" %> | |
9 | + <%= hidden_field_tag "gov_user_plugin[institution_id]", "", id: "institution_selected" %> | |
12 | 10 | </div> | ... | ... |