Project

General

Profile

Defect #27584 ยป test_issue_27584.diff

Toshi MARUYAMA, 2017-12-12 18:57

View differences:

test/integration/api_test/projects_test.rb
158 158
    assert_select 'project id', :text => project.id.to_s
159 159
  end
160 160

  
161
  def test_issue_27584
162
    with_settings :default_projects_modules => [] do
163
      assert_difference('Project.count') do
164
        post '/projects.xml',
165
          :params => {:project => {:name => 'API test', :identifier => 'api-test'}},
166
          :headers => credentials('admin')
167
      end
168
    end
169

  
170
    project = Project.order('id DESC').first
171
    assert_equal 'API test', project.name
172
    assert_equal 'api-test', project.identifier
173
    assert_equal [], project.enabled_module_names.sort
174
    assert_equal Tracker.all.size, project.trackers.size
175

  
176
    assert_response :created
177
    assert_equal 'application/xml', @response.content_type
178
    assert_select 'project id', :text => project.id.to_s
179

  
180
    project.reload
181

  
182
    assert_no_difference 'Project.count' do
183
      put "/projects/#{project.id}.xml",
184
        :params => {:project => {:enabled_module_names => ['issue_tracking']}},
185
        :headers => credentials('admin')
186
    end
187
    assert_response :ok
188
    assert_equal '', @response.body
189
    project.reload
190
    assert_equal ['issue_tracking'], project.enabled_module_names.sort
191

  
192
    assert_no_difference 'Project.count' do
193
      put "/projects/#{project.id}.xml",
194
        :params => {:project => {:enabled_module_names => ['news']}},
195
        :headers => credentials('admin')
196
    end
197
    assert_response :ok
198
    assert_equal '', @response.body
199
    project.reload
200
    assert_equal ['news'], project.enabled_module_names.sort
201
  end
202

  
161 203
  test "POST /projects.xml should accept enabled_module_names attribute" do
162 204
    assert_difference('Project.count') do
163 205
      post '/projects.xml',
    (1-1/1)