Skip to content

Commit

Permalink
User lobby can not destroy agents
Browse files Browse the repository at this point in the history
  • Loading branch information
taitus committed Dec 21, 2017
1 parent 5cc3a6c commit 82ef79c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
14 changes: 7 additions & 7 deletions app/controllers/admin/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def organization_params
:web, :address_type, :address, :number, :gateway, :stairs, :floor, :door,
:postal_code, :town, :province, :description, :registered_lobbies, :category_id,
:fiscal_year, :range_fund, :subvention, :contract, :denied_public_data, :denied_public_events, interest_ids: [],
legal_representant_attributes: [:identifier, :name, :first_surname, :second_surname, :phones, :email, :_destroy],
user_attributes: [:id, :first_name, :last_name, :role, :email, :active, :phones, :password, :password_confirmation],
represented_entities_attributes: [:id, :identifier, :name, :first_surname, :second_surname,
:from, :fiscal_year, :range_fund, :subvention, :contract, :_destroy],
organization_interests_attributes: [:interest_ids],
agents_attributes: [:id, :identifier, :name, :first_surname, :second_surname, :from,
:to, :public_assignments, :_destroy])
legal_representant_attributes: [:identifier, :name, :first_surname, :second_surname, :phones, :email, :_destroy],
user_attributes: [:id, :first_name, :last_name, :role, :email, :active, :phones, :password, :password_confirmation],
represented_entities_attributes: [:id, :identifier, :name, :first_surname, :second_surname,
:from, :fiscal_year, :range_fund, :subvention, :contract, :_destroy],
organization_interests_attributes: [:interest_ids],
agents_attributes: [:id, :identifier, :name, :first_surname, :second_surname, :from,
:to, :public_assignments, :_destroy])
end

def set_organization
Expand Down
2 changes: 1 addition & 1 deletion app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Organization < ActiveRecord::Base
accepts_nested_attributes_for :legal_representant, update_only: true, allow_destroy: true
accepts_nested_attributes_for :user
accepts_nested_attributes_for :represented_entities, allow_destroy: true
accepts_nested_attributes_for :agents, allow_destroy: true
accepts_nested_attributes_for :agents, allow_destroy: true, reject_if: :all_blank

after_create :set_inscription_date, :set_invalidate

Expand Down
13 changes: 7 additions & 6 deletions app/views/admin/organizations/_agents_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
<%= f.text_area :public_assignments, class: 'mceNoEditor' %>
<%= form_field_errors(f, :public_assignments) %>
</div>

<div class="small-12 columns">
<br />
<%= link_to_remove_association "Eliminar", f, class: "button tiny radius alert right" %>
<hr />
</div>
<% if current_user.admin? %>
<div class="small-12 columns">
<br />
<%= link_to_remove_association "Eliminar", f, class: "button tiny radius alert right" %>
<hr />
</div>
<% end %>

</div>
12 changes: 12 additions & 0 deletions spec/features/admin/organizations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,18 @@
expect(page).to have_content 'no puede estar en blanco'
end

scenario 'Can not destroy agents', :js do
visit admin_path

click_link I18n.t("backend.edit_agents")
click_link I18n.t('backend.agents.add_association')

within '#nested-agents' do
expect(page).not_to have_content 'Eliminar'
end
end


scenario 'Can add interests' do
visit admin_path

Expand Down

0 comments on commit 82ef79c

Please sign in to comment.