respond_to do |format|
format.html
- format.js do
- render :update do |page|
- page.replace_html 'ajax-modal', :partial => 'issue_categories/new_modal'
- page << "showModal('ajax-modal', '600px');"
- page << "Form.Element.focus('issue_category_name');"
- end
- end
+ format.js
end
end
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
end
- format.js do
- render(:update) {|page|
- page << 'hideModal();'
- # IE doesn't support the replace_html rjs method for select box options
- page.replace "issue_category_id",
- content_tag('select', content_tag('option') + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
- }
- end
+ format.js
format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
end
else
respond_to do |format|
format.html { render :action => 'new'}
- format.js do
- render :update do |page|
- page.replace_html 'ajax-modal', :partial => 'issue_categories/new_modal'
- page << "Form.Element.focus('version_name');"
- end
- end
+ format.js { render :action => 'new'}
format.api { render_validation_errors(@category) }
end
end
respond_to do |format|
format.html
- format.js do
- render :update do |page|
- page.replace_html 'ajax-modal', :partial => 'versions/new_modal'
- page << "showModal('ajax-modal', '600px');"
- page << "Form.Element.focus('version_name');"
- end
- end
+ format.js
end
end
flash[:notice] = l(:notice_successful_create)
redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
end
- format.js do
- render(:update) {|page|
- page << 'hideModal();'
- # IE doesn't support the replace_html rjs method for select box options
- page.replace "issue_fixed_version_id",
- content_tag('select', content_tag('option') + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]')
- }
- end
+ format.js
format.api do
render :action => 'show', :status => :created, :location => version_url(@version)
end
else
respond_to do |format|
format.html { render :action => 'new' }
- format.js do
- render :update do |page|
- page.replace_html 'ajax-modal', :partial => 'versions/new_modal'
- page << "Form.Element.focus('version_name');"
- end
- end
+ format.js { render :action => 'new' }
format.api { render_validation_errors(@version) }
end
end
--- /dev/null
+hideModal();
+<% select = content_tag('select', content_tag('option') + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') %>
+Element.replace('issue_category_id', '<%= escape_javascript(select) %>');
--- /dev/null
+Element.update('ajax-modal', '<%= escape_javascript(render :partial => 'issue_categories/new_modal') %>');
+showModal('ajax-modal', '600px');
+Form.Element.focus('issue_category_name');
--- /dev/null
+hideModal();
+<% select = content_tag('select', content_tag('option') + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') %>
+Element.replace('issue_fixed_version_id', '<%= escape_javascript(select) %>');
--- /dev/null
+Element.update('ajax-modal', '<%= escape_javascript(render :partial => 'versions/new_modal') %>');
+showModal('ajax-modal', '600px');
+Form.Element.focus('version_name');
assert_select 'input[name=?]', 'issue_category[name]'
end
+ def test_new_from_issue_form
+ @request.session[:user_id] = 2 # manager
+ xhr :get, :new, :project_id => '1'
+
+ assert_response :success
+ assert_template 'new'
+ assert_equal 'text/javascript', response.content_type
+ end
+
def test_create
@request.session[:user_id] = 2 # manager
assert_difference 'IssueCategory.count' do
assert_equal 'New category', category.name
assert_response :success
- assert_select_rjs :replace, 'issue_category_id' do
- assert_select "option[value=#{category.id}][selected=selected]"
- end
+ assert_template 'create'
+ assert_equal 'text/javascript', response.content_type
end
def test_create_from_issue_form_with_failure
end
assert_response :success
- assert_select_rjs :replace_html, "ajax-modal" do
- assert_select "div#errorExplanation"
- end
+ assert_template 'new'
+ assert_equal 'text/javascript', response.content_type
end
def test_edit
@request.session[:user_id] = 2
xhr :get, :new, :project_id => '1'
assert_response :success
- assert_select_rjs :replace_html, "ajax-modal" do
- assert_select "form[action=/projects/ecookbook/versions]"
- assert_select "input#version_name"
- end
+ assert_template 'new'
+ assert_equal 'text/javascript', response.content_type
end
def test_create
assert_equal 1, version.project_id
assert_response :success
- assert_select_rjs :replace, 'issue_fixed_version_id' do
- assert_select "option[value=#{version.id}][selected=selected]"
- end
+ assert_template 'create'
+ assert_equal 'text/javascript', response.content_type
end
def test_create_from_issue_form_with_failure
xhr :post, :create, :project_id => '1', :version => {:name => ''}
end
assert_response :success
- assert_select_rjs :replace_html, "ajax-modal" do
- assert_select "div#errorExplanation"
- end
+ assert_template 'new'
+ assert_equal 'text/javascript', response.content_type
end
def test_get_edit