update aspect name in page listing after editing.
This commit is contained in:
parent
a304cb1d33
commit
ef7dc1c017
3 changed files with 13 additions and 1 deletions
|
|
@ -107,7 +107,7 @@ class AspectsController < ApplicationController
|
|||
else
|
||||
flash[:error] = I18n.t 'aspects.update.failure', :name => @aspect.name
|
||||
end
|
||||
render :json => { :name => @aspect.name }
|
||||
render :json => { :id => @aspect.id, :name => @aspect.name }
|
||||
end
|
||||
|
||||
def toggle_contact_visibility
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ function updateAspectName(new_name) {
|
|||
$('#aspect_name_title .name').html(new_name);
|
||||
$('input#aspect_name').val(new_name);
|
||||
}
|
||||
function updatePageAspectName( an_id, new_name) {
|
||||
$('ul#aspect_nav [data-guid="'+an_id+'"]').html(new_name);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#rename_aspect_link').live('click', function(){
|
||||
|
|
@ -20,6 +23,7 @@ $(document).ready(function() {
|
|||
|
||||
$('form.edit_aspect').live('ajax:success', function(evt, data, status, xhr) {
|
||||
updateAspectName(data['name']);
|
||||
updatePageAspectName( data['id'], data['name'] );
|
||||
toggleAspectTitle();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -104,6 +104,14 @@ describe AspectsController do
|
|||
put('update', :id => @alices_aspect_1.id, "aspect" => params)
|
||||
Aspect.find(@alices_aspect_1.id).user_id.should == alice.id
|
||||
end
|
||||
|
||||
it "should return the name and id of the updated item" do
|
||||
params = {"name" => "Bruisers"}
|
||||
put('update', :id => @alices_aspect_1.id, "aspect" => params)
|
||||
|
||||
puts( response.inspect )
|
||||
response.body.should == { :id => @alices_aspect_1.id, :name => "Bruisers" }.to_json
|
||||
end
|
||||
end
|
||||
|
||||
describe '#edit' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue