Tests/cleanup VersionsController.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8038 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
666830cca0
commit
8bbb5d9686
@ -71,16 +71,10 @@ class VersionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@version = @project.versions.build
|
@version = @project.versions.build(params[:version])
|
||||||
if params[:version]
|
|
||||||
attributes = params[:version].dup
|
|
||||||
attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
|
|
||||||
@version.attributes = attributes
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
# TODO: refactor with code above in #new
|
|
||||||
@version = @project.versions.build
|
@version = @project.versions.build
|
||||||
if params[:version]
|
if params[:version]
|
||||||
attributes = params[:version].dup
|
attributes = params[:version].dup
|
||||||
|
@ -55,6 +55,14 @@ class VersionsControllerTest < ActionController::TestCase
|
|||||||
assert assigns(:versions).include?(Version.find(1))
|
assert assigns(:versions).include?(Version.find(1))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_index_with_tracker_ids
|
||||||
|
get :index, :project_id => 1, :tracker_ids => [1, 3]
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'index'
|
||||||
|
assert_not_nil assigns(:issues_by_version)
|
||||||
|
assert_nil assigns(:issues_by_version).values.flatten.detect {|issue| issue.tracker_id == 2}
|
||||||
|
end
|
||||||
|
|
||||||
def test_index_showing_subprojects_versions
|
def test_index_showing_subprojects_versions
|
||||||
@subproject_version = Version.generate!(:project => Project.find(3))
|
@subproject_version = Version.generate!(:project => Project.find(3))
|
||||||
get :index, :project_id => 1, :with_subprojects => 1
|
get :index, :project_id => 1, :with_subprojects => 1
|
||||||
@ -75,6 +83,13 @@ class VersionsControllerTest < ActionController::TestCase
|
|||||||
assert_tag :tag => 'h2', :content => /1.0/
|
assert_tag :tag => 'h2', :content => /1.0/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_new
|
||||||
|
@request.session[:user_id] = 2
|
||||||
|
get :new, :project_id => '1'
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'new'
|
||||||
|
end
|
||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
@request.session[:user_id] = 2 # manager
|
@request.session[:user_id] = 2 # manager
|
||||||
assert_difference 'Version.count' do
|
assert_difference 'Version.count' do
|
||||||
@ -135,11 +150,23 @@ class VersionsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
delete :destroy, :id => 3
|
assert_difference 'Version.count', -1 do
|
||||||
|
delete :destroy, :id => 3
|
||||||
|
end
|
||||||
assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
|
assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
|
||||||
assert_nil Version.find_by_id(3)
|
assert_nil Version.find_by_id(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_destroy_version_in_use_should_fail
|
||||||
|
@request.session[:user_id] = 2
|
||||||
|
assert_no_difference 'Version.count' do
|
||||||
|
delete :destroy, :id => 2
|
||||||
|
end
|
||||||
|
assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
|
||||||
|
assert flash[:error].match(/Unable to delete version/)
|
||||||
|
assert Version.find_by_id(2)
|
||||||
|
end
|
||||||
|
|
||||||
def test_issue_status_by
|
def test_issue_status_by
|
||||||
xhr :get, :status_by, :id => 2
|
xhr :get, :status_by, :id => 2
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
Loading…
x
Reference in New Issue
Block a user