##// END OF EJS Templates
Tests/cleanup VersionsController....
Jean-Philippe Lang -
r7918:8bbb5d9686fb
parent child
Show More
@@ -71,16 +71,10 class VersionsController < ApplicationController
71 71 end
72 72
73 73 def new
74 @version = @project.versions.build
75 if params[:version]
76 attributes = params[:version].dup
77 attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
78 @version.attributes = attributes
79 end
74 @version = @project.versions.build(params[:version])
80 75 end
81 76
82 77 def create
83 # TODO: refactor with code above in #new
84 78 @version = @project.versions.build
85 79 if params[:version]
86 80 attributes = params[:version].dup
@@ -55,6 +55,14 class VersionsControllerTest < ActionController::TestCase
55 55 assert assigns(:versions).include?(Version.find(1))
56 56 end
57 57
58 def test_index_with_tracker_ids
59 get :index, :project_id => 1, :tracker_ids => [1, 3]
60 assert_response :success
61 assert_template 'index'
62 assert_not_nil assigns(:issues_by_version)
63 assert_nil assigns(:issues_by_version).values.flatten.detect {|issue| issue.tracker_id == 2}
64 end
65
58 66 def test_index_showing_subprojects_versions
59 67 @subproject_version = Version.generate!(:project => Project.find(3))
60 68 get :index, :project_id => 1, :with_subprojects => 1
@@ -75,6 +83,13 class VersionsControllerTest < ActionController::TestCase
75 83 assert_tag :tag => 'h2', :content => /1.0/
76 84 end
77 85
86 def test_new
87 @request.session[:user_id] = 2
88 get :new, :project_id => '1'
89 assert_response :success
90 assert_template 'new'
91 end
92
78 93 def test_create
79 94 @request.session[:user_id] = 2 # manager
80 95 assert_difference 'Version.count' do
@@ -135,11 +150,23 class VersionsControllerTest < ActionController::TestCase
135 150
136 151 def test_destroy
137 152 @request.session[:user_id] = 2
138 delete :destroy, :id => 3
153 assert_difference 'Version.count', -1 do
154 delete :destroy, :id => 3
155 end
139 156 assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
140 157 assert_nil Version.find_by_id(3)
141 158 end
142 159
160 def test_destroy_version_in_use_should_fail
161 @request.session[:user_id] = 2
162 assert_no_difference 'Version.count' do
163 delete :destroy, :id => 2
164 end
165 assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
166 assert flash[:error].match(/Unable to delete version/)
167 assert Version.find_by_id(2)
168 end
169
143 170 def test_issue_status_by
144 171 xhr :get, :status_by, :id => 2
145 172 assert_response :success
General Comments 0
You need to be logged in to leave comments. Login now