@@ -71,16 +71,10 class VersionsController < ApplicationController | |||||
71 | end |
|
71 | end | |
72 |
|
72 | |||
73 | def new |
|
73 | def new | |
74 | @version = @project.versions.build |
|
74 | @version = @project.versions.build(params[:version]) | |
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 |
|
|||
80 | end |
|
75 | end | |
81 |
|
76 | |||
82 | def create |
|
77 | def create | |
83 | # TODO: refactor with code above in #new |
|
|||
84 | @version = @project.versions.build |
|
78 | @version = @project.versions.build | |
85 | if params[:version] |
|
79 | if params[:version] | |
86 | attributes = params[:version].dup |
|
80 | attributes = params[:version].dup |
@@ -55,6 +55,14 class VersionsControllerTest < ActionController::TestCase | |||||
55 | assert assigns(:versions).include?(Version.find(1)) |
|
55 | assert assigns(:versions).include?(Version.find(1)) | |
56 | end |
|
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 | def test_index_showing_subprojects_versions |
|
66 | def test_index_showing_subprojects_versions | |
59 | @subproject_version = Version.generate!(:project => Project.find(3)) |
|
67 | @subproject_version = Version.generate!(:project => Project.find(3)) | |
60 | get :index, :project_id => 1, :with_subprojects => 1 |
|
68 | get :index, :project_id => 1, :with_subprojects => 1 | |
@@ -75,6 +83,13 class VersionsControllerTest < ActionController::TestCase | |||||
75 | assert_tag :tag => 'h2', :content => /1.0/ |
|
83 | assert_tag :tag => 'h2', :content => /1.0/ | |
76 | end |
|
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 | def test_create |
|
93 | def test_create | |
79 | @request.session[:user_id] = 2 # manager |
|
94 | @request.session[:user_id] = 2 # manager | |
80 | assert_difference 'Version.count' do |
|
95 | assert_difference 'Version.count' do | |
@@ -135,11 +150,23 class VersionsControllerTest < ActionController::TestCase | |||||
135 |
|
150 | |||
136 | def test_destroy |
|
151 | def test_destroy | |
137 | @request.session[:user_id] = 2 |
|
152 | @request.session[:user_id] = 2 | |
|
153 | assert_difference 'Version.count', -1 do | |||
138 | delete :destroy, :id => 3 |
|
154 | delete :destroy, :id => 3 | |
|
155 | end | |||
139 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' |
|
156 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' | |
140 | assert_nil Version.find_by_id(3) |
|
157 | assert_nil Version.find_by_id(3) | |
141 | end |
|
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 | def test_issue_status_by |
|
170 | def test_issue_status_by | |
144 | xhr :get, :status_by, :id => 2 |
|
171 | xhr :get, :status_by, :id => 2 | |
145 | assert_response :success |
|
172 | assert_response :success |
General Comments 0
You need to be logged in to leave comments.
Login now