@@ -0,0 +1,3 | |||
|
1 | hideModal(); | |
|
2 | <% 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]') %> | |
|
3 | Element.replace('issue_category_id', '<%= escape_javascript(select) %>'); |
@@ -0,0 +1,3 | |||
|
1 | Element.update('ajax-modal', '<%= escape_javascript(render :partial => 'issue_categories/new_modal') %>'); | |
|
2 | showModal('ajax-modal', '600px'); | |
|
3 | Form.Element.focus('issue_category_name'); |
@@ -0,0 +1,3 | |||
|
1 | hideModal(); | |
|
2 | <% 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]') %> | |
|
3 | Element.replace('issue_fixed_version_id', '<%= escape_javascript(select) %>'); |
@@ -0,0 +1,3 | |||
|
1 | Element.update('ajax-modal', '<%= escape_javascript(render :partial => 'versions/new_modal') %>'); | |
|
2 | showModal('ajax-modal', '600px'); | |
|
3 | Form.Element.focus('version_name'); |
@@ -44,13 +44,7 class IssueCategoriesController < ApplicationController | |||
|
44 | 44 | |
|
45 | 45 | respond_to do |format| |
|
46 | 46 | format.html |
|
47 |
format.js |
|
|
48 | render :update do |page| | |
|
49 | page.replace_html 'ajax-modal', :partial => 'issue_categories/new_modal' | |
|
50 | page << "showModal('ajax-modal', '600px');" | |
|
51 | page << "Form.Element.focus('issue_category_name');" | |
|
52 | end | |
|
53 | end | |
|
47 | format.js | |
|
54 | 48 | end |
|
55 | 49 | end |
|
56 | 50 | |
@@ -63,25 +57,13 class IssueCategoriesController < ApplicationController | |||
|
63 | 57 | flash[:notice] = l(:notice_successful_create) |
|
64 | 58 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project |
|
65 | 59 | end |
|
66 |
format.js |
|
|
67 | render(:update) {|page| | |
|
68 | page << 'hideModal();' | |
|
69 | # IE doesn't support the replace_html rjs method for select box options | |
|
70 | page.replace "issue_category_id", | |
|
71 | 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]') | |
|
72 | } | |
|
73 | end | |
|
60 | format.js | |
|
74 | 61 | format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) } |
|
75 | 62 | end |
|
76 | 63 | else |
|
77 | 64 | respond_to do |format| |
|
78 | 65 | format.html { render :action => 'new'} |
|
79 | format.js do | |
|
80 | render :update do |page| | |
|
81 | page.replace_html 'ajax-modal', :partial => 'issue_categories/new_modal' | |
|
82 | page << "Form.Element.focus('version_name');" | |
|
83 | end | |
|
84 | end | |
|
66 | format.js { render :action => 'new'} | |
|
85 | 67 | format.api { render_validation_errors(@category) } |
|
86 | 68 | end |
|
87 | 69 | end |
@@ -78,13 +78,7 class VersionsController < ApplicationController | |||
|
78 | 78 | |
|
79 | 79 | respond_to do |format| |
|
80 | 80 | format.html |
|
81 |
format.js |
|
|
82 | render :update do |page| | |
|
83 | page.replace_html 'ajax-modal', :partial => 'versions/new_modal' | |
|
84 | page << "showModal('ajax-modal', '600px');" | |
|
85 | page << "Form.Element.focus('version_name');" | |
|
86 | end | |
|
87 | end | |
|
81 | format.js | |
|
88 | 82 | end |
|
89 | 83 | end |
|
90 | 84 | |
@@ -103,14 +97,7 class VersionsController < ApplicationController | |||
|
103 | 97 | flash[:notice] = l(:notice_successful_create) |
|
104 | 98 | redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
105 | 99 | end |
|
106 |
format.js |
|
|
107 | render(:update) {|page| | |
|
108 | page << 'hideModal();' | |
|
109 | # IE doesn't support the replace_html rjs method for select box options | |
|
110 | page.replace "issue_fixed_version_id", | |
|
111 | 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]') | |
|
112 | } | |
|
113 | end | |
|
100 | format.js | |
|
114 | 101 | format.api do |
|
115 | 102 | render :action => 'show', :status => :created, :location => version_url(@version) |
|
116 | 103 | end |
@@ -118,12 +105,7 class VersionsController < ApplicationController | |||
|
118 | 105 | else |
|
119 | 106 | respond_to do |format| |
|
120 | 107 | format.html { render :action => 'new' } |
|
121 | format.js do | |
|
122 | render :update do |page| | |
|
123 | page.replace_html 'ajax-modal', :partial => 'versions/new_modal' | |
|
124 | page << "Form.Element.focus('version_name');" | |
|
125 | end | |
|
126 | end | |
|
108 | format.js { render :action => 'new' } | |
|
127 | 109 | format.api { render_validation_errors(@version) } |
|
128 | 110 | end |
|
129 | 111 | end |
@@ -40,6 +40,15 class IssueCategoriesControllerTest < ActionController::TestCase | |||
|
40 | 40 | assert_select 'input[name=?]', 'issue_category[name]' |
|
41 | 41 | end |
|
42 | 42 | |
|
43 | def test_new_from_issue_form | |
|
44 | @request.session[:user_id] = 2 # manager | |
|
45 | xhr :get, :new, :project_id => '1' | |
|
46 | ||
|
47 | assert_response :success | |
|
48 | assert_template 'new' | |
|
49 | assert_equal 'text/javascript', response.content_type | |
|
50 | end | |
|
51 | ||
|
43 | 52 | def test_create |
|
44 | 53 | @request.session[:user_id] = 2 # manager |
|
45 | 54 | assert_difference 'IssueCategory.count' do |
@@ -67,9 +76,8 class IssueCategoriesControllerTest < ActionController::TestCase | |||
|
67 | 76 | assert_equal 'New category', category.name |
|
68 | 77 | |
|
69 | 78 | assert_response :success |
|
70 | assert_select_rjs :replace, 'issue_category_id' do | |
|
71 | assert_select "option[value=#{category.id}][selected=selected]" | |
|
72 | end | |
|
79 | assert_template 'create' | |
|
80 | assert_equal 'text/javascript', response.content_type | |
|
73 | 81 | end |
|
74 | 82 | |
|
75 | 83 | def test_create_from_issue_form_with_failure |
@@ -79,9 +87,8 class IssueCategoriesControllerTest < ActionController::TestCase | |||
|
79 | 87 | end |
|
80 | 88 | |
|
81 | 89 | assert_response :success |
|
82 | assert_select_rjs :replace_html, "ajax-modal" do | |
|
83 | assert_select "div#errorExplanation" | |
|
84 | end | |
|
90 | assert_template 'new' | |
|
91 | assert_equal 'text/javascript', response.content_type | |
|
85 | 92 | end |
|
86 | 93 | |
|
87 | 94 | def test_edit |
@@ -100,10 +100,8 class VersionsControllerTest < ActionController::TestCase | |||
|
100 | 100 | @request.session[:user_id] = 2 |
|
101 | 101 | xhr :get, :new, :project_id => '1' |
|
102 | 102 | assert_response :success |
|
103 | assert_select_rjs :replace_html, "ajax-modal" do | |
|
104 | assert_select "form[action=/projects/ecookbook/versions]" | |
|
105 | assert_select "input#version_name" | |
|
106 | end | |
|
103 | assert_template 'new' | |
|
104 | assert_equal 'text/javascript', response.content_type | |
|
107 | 105 | end |
|
108 | 106 | |
|
109 | 107 | def test_create |
@@ -127,9 +125,8 class VersionsControllerTest < ActionController::TestCase | |||
|
127 | 125 | assert_equal 1, version.project_id |
|
128 | 126 | |
|
129 | 127 | assert_response :success |
|
130 | assert_select_rjs :replace, 'issue_fixed_version_id' do | |
|
131 | assert_select "option[value=#{version.id}][selected=selected]" | |
|
132 | end | |
|
128 | assert_template 'create' | |
|
129 | assert_equal 'text/javascript', response.content_type | |
|
133 | 130 | end |
|
134 | 131 | |
|
135 | 132 | def test_create_from_issue_form_with_failure |
@@ -138,9 +135,8 class VersionsControllerTest < ActionController::TestCase | |||
|
138 | 135 | xhr :post, :create, :project_id => '1', :version => {:name => ''} |
|
139 | 136 | end |
|
140 | 137 | assert_response :success |
|
141 | assert_select_rjs :replace_html, "ajax-modal" do | |
|
142 | assert_select "div#errorExplanation" | |
|
143 | end | |
|
138 | assert_template 'new' | |
|
139 | assert_equal 'text/javascript', response.content_type | |
|
144 | 140 | end |
|
145 | 141 | |
|
146 | 142 | def test_get_edit |
General Comments 0
You need to be logged in to leave comments.
Login now