diff --git a/app/views/people/_person.html.haml b/app/views/people/_person.html.haml index 6339671c115565bbc2b39ac7b71b83f2b4da93fa..62dbf9351354df94cf7d9fbec91d6b9ef7a13e1c 100644 --- a/app/views/people/_person.html.haml +++ b/app/views/people/_person.html.haml @@ -18,10 +18,10 @@ - elsif current_user.pending_requests.find_by_person_id(person.id) = link_to =t('.pending_request'), aspects_manage_path - else - = form_for Request.new do |f| - = f.select(:into_id, @aspects_dropdown_array) - = f.hidden_field :destination_url, :value => person.diaspora_handle - = f.submit t('.add_friend') + = form_tag(requests_path) do + = select_tag(:aspect_id, @aspects_dropdown_array.join.html_safe) + = hidden_field_tag :destination_handle, :value => person.diaspora_handle + = submit_tag t('.add_friend') .info = person.diaspora_handle diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index b0b53ae18c874226df178bc9fd645d05d89979c1..0486b63e41fc0739ab2cfb0bbed6a1cab4cbf81e 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -30,10 +30,10 @@ .description = t('.request_people') - = form_for Request.new do |f| - = f.select(:aspect_id, @aspects_dropdown_array) - = f.hidden_field :destination_url, :value => @person.diaspora_handle - = f.submit t('.add_friend') + = form_tag(requests_path) do + = select_tag(:aspect_id, @aspects_dropdown_array.join.html_safe) + = hidden_field_tag :destination_handle, :value => @person.diaspora_handle + = submit_tag t('.add_friend') - else %h3 diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 106a74760b0544dff88703c67c049bf965b2a30d..efa8d38e3f1472a822dffbf3ce957e04456fb591 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -14,25 +14,59 @@ describe PeopleController do sign_in :user, user end - it "index should yield search results for substring of person name" do - eugene = Factory.create(:person, :profile => {:first_name => "Eugene", :last_name => "w"}) - get :index, :q => "Eu" - assigns[:people].should include eugene - end + describe '#index' do + it "yields search results for substring of person name" do + eugene = Factory.create(:person, :profile => {:first_name => "Eugene", :last_name => "w"}) + get :index, :q => "Eu" + assigns[:people].should include eugene + end - it 'should go to the current_user show page' do - get :show, :id => user.person.id - response.should be_success - end + it 'shows a friend' do + user2 = make_user + friend_users(user, aspect, user2, user2.aspects.create(:name => 'Neuroscience')) + get :index + assigns[:people].should include user2.person + response.should be_success + end - it "redirects on an invalid id" do - get :show, :id => 'delicious' - response.should redirect_to people_path + it 'shows a non-friend' do + user2 = make_user + user2.person.profile.searchable = true + user2.save + get :index + assigns[:people].should include user2.person + response.should be_success + end end - it "redirects on a nonexistent person" do - get :show, :id => user.id - response.should redirect_to people_path + describe '#show' do + it 'should go to the current_user show page' do + get :show, :id => user.person.id + response.should be_success + end + + it "redirects on an invalid id" do + get :show, :id => 'delicious' + response.should redirect_to people_path + end + + it "redirects on a nonexistent person" do + get :show, :id => user.id + response.should redirect_to people_path + end + + it "renders the show page of a friend" do + user2 = make_user + friend_users(user, aspect, user2, user2.aspects.create(:name => 'Neuroscience')) + get :show, :id => user2.person.id + response.should be_success + end + + it "renders the show page of a non-friend" do + user2 = make_user + get :show, :id => user2.person.id + response.should be_success + end end describe '#update' do