summaryrefslogtreecommitdiffstats
path: root/test/functional/versions_controller_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/versions_controller_test.rb')
-rw-r--r--test/functional/versions_controller_test.rb30
1 files changed, 27 insertions, 3 deletions
diff --git a/test/functional/versions_controller_test.rb b/test/functional/versions_controller_test.rb
index 9ba301bc5..fe5d3f895 100644
--- a/test/functional/versions_controller_test.rb
+++ b/test/functional/versions_controller_test.rb
@@ -96,6 +96,16 @@ class VersionsControllerTest < ActionController::TestCase
assert_template 'new'
end
+ def test_new_from_issue_form
+ @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
+ end
+
def test_create
@request.session[:user_id] = 2 # manager
assert_difference 'Version.count' do
@@ -108,15 +118,29 @@ class VersionsControllerTest < ActionController::TestCase
end
def test_create_from_issue_form
- @request.session[:user_id] = 2 # manager
+ @request.session[:user_id] = 2
assert_difference 'Version.count' do
xhr :post, :create, :project_id => '1', :version => {:name => 'test_add_version_from_issue_form'}
end
- assert_response :success
- assert_select_rjs :replace, 'issue_fixed_version_id'
version = Version.find_by_name('test_add_version_from_issue_form')
assert_not_nil version
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
+ end
+
+ def test_create_from_issue_form_with_failure
+ @request.session[:user_id] = 2
+ assert_no_difference 'Version.count' do
+ 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
end
def test_get_edit