Skip to content
Snippets Groups Projects
Commit 62700387 authored by ilya's avatar ilya
Browse files

MS IZ added an add to aspect form on the request partial

parent 0afe83b5
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,7 @@ class AspectsController < ApplicationController
def show
@aspect = current_user.aspect_by_id params[:id]
@friends_dropdown_array = current_user.friends.all(:person_id.nin => @aspect.person_ids )
unless @aspect
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
else
......@@ -92,13 +93,13 @@ class AspectsController < ApplicationController
end
def add_to_aspect
if current_user.add_person_to_aspect( params[:friend_id], params[:to_aspect_id])
if current_user.add_person_to_aspect( params[:friend_id], params[:aspect_id])
flash[:notice] = I18n.t 'aspects.add_to_aspect.success'
render :nothing => true
else
flash[:notice] = I18n.t 'aspects.add_to_aspect.success'
render :nothing => true, :status => 500
end
redirect_to aspects_path(params[:aspect_id])
end
private
......
......@@ -8,6 +8,14 @@
=t('.add_a_new_friend_to')
%i= aspect.name
= form_tag '/aspects/add_to_aspect', :id => 'add_to_aspect' do
= select_tag :friend_id, options_from_collection_for_select(@friends_dropdown_array, "id", "real_name"), :include_blank => true
= hidden_field_tag :aspect_id, aspect.id
= submit_tag "add to #{@aspect.name}"
= form_for Request.new do |fr_request|
= fr_request.error_messages
......
......@@ -76,7 +76,7 @@ describe AspectsController do
it 'adds the users to the aspect' do
@aspect1.reload
@aspect1.people.include?(@user2.person).should be false
post 'add_to_aspect', {'friend_id' => @user2.person.id, 'to_aspect_id' => @aspect1.id }
post 'add_to_aspect', {:friend_id => @user2.person.id, :aspect_id => @aspect1.id }
@aspect1.reload
@aspect1.people.include?(@user2.person).should be true
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment