30073.diff

Go MAEDA, 2019-02-03 12:25

Download (13.5 KB)

View differences:

app/controllers/application_controller.rb (working copy)
659 659

  
660 660
  # Renders a 200 response for successful updates or deletions via the API
661 661
  def render_api_ok
662
    render_api_head :ok
662
    render_api_head :no_content
663 663
  end
664 664

  
665 665
  # Renders a head API response
test/integration/api_test/api_test.rb (working copy)
49 49
  def test_head_response_should_have_empty_body
50 50
    put '/users/7.xml', :params => {:user => {:login => 'foo'}}, :headers => credentials('admin')
51 51

  
52
    assert_response :ok
52
    assert_response :no_content
53 53
    assert_equal '', response.body
54 54
  end
55 55
end
test/integration/api_test/attachments_test.rb (working copy)
84 84
  test "DELETE /attachments/:id.xml should return ok and delete Attachment" do
85 85
    assert_difference 'Attachment.count', -1 do
86 86
      delete '/attachments/7.xml', :headers => credentials('jsmith')
87
      assert_response :ok
87
      assert_response :no_content
88 88
      assert_equal '', response.body
89 89
    end
90 90
    assert_nil Attachment.find_by_id(7)
......
93 93
  test "DELETE /attachments/:id.json should return ok and delete Attachment" do
94 94
    assert_difference 'Attachment.count', -1 do
95 95
      delete '/attachments/7.json', :headers => credentials('jsmith')
96
      assert_response :ok
96
      assert_response :no_content
97 97
      assert_equal '', response.body
98 98
    end
99 99
    assert_nil Attachment.find_by_id(7)
......
104 104
      :params => {:attachment => {:filename => 'renamed.zip', :description => 'updated'}},
105 105
      :headers => credentials('jsmith')
106 106

  
107
    assert_response :ok
108
    assert_equal 'application/json', response.content_type
107
    assert_response :no_content
108
    assert_nil response.content_type
109 109
    attachment = Attachment.find(7)
110 110
    assert_equal 'renamed.zip', attachment.filename
111 111
    assert_equal 'updated', attachment.description
test/integration/api_test/groups_test.rb (working copy)
157 157
    put "/groups/#{group.id}.xml",
158 158
      :params => {:group => {:name => 'New name', :user_ids => [2, 3]}},
159 159
      :headers => credentials('admin')
160
    assert_response :ok
160
    assert_response :no_content
161 161
    assert_equal '', @response.body
162 162

  
163 163
    assert_equal 'New name', group.reload.name
......
181 181
    group = Group.generate!
182 182
    assert_difference 'Group.count', -1 do
183 183
      delete "/groups/#{group.id}.xml", :headers => credentials('admin')
184
      assert_response :ok
184
      assert_response :no_content
185 185
      assert_equal '', @response.body
186 186
    end
187 187
  end
......
192 192
      post "/groups/#{group.id}/users.xml",
193 193
        :params => {:user_id => 5},
194 194
        :headers => credentials('admin')
195
      assert_response :ok
195
      assert_response :no_content
196 196
      assert_equal '', @response.body
197 197
    end
198 198
    assert_include User.find(5), group.reload.users
......
220 220

  
221 221
    assert_difference 'group.reload.users.count', -1 do
222 222
      delete "/groups/#{group.id}/users/8.xml", :headers => credentials('admin')
223
      assert_response :ok
223
      assert_response :no_content
224 224
      assert_equal '', @response.body
225 225
    end
226 226
    assert_not_include User.find(8), group.reload.users
test/integration/api_test/issue_categories_test.rb (working copy)
70 70
        :params => {:issue_category => {:name => 'API Update'}},
71 71
        :headers => credentials('jsmith')
72 72
    end
73
    assert_response :ok
73
    assert_response :no_content
74 74
    assert_equal '', @response.body
75 75
    assert_equal 'API Update', IssueCategory.find(2).name
76 76
  end
......
91 91
    assert_difference 'IssueCategory.count', -1 do
92 92
      delete '/issue_categories/1.xml', :headers => credentials('jsmith')
93 93
    end
94
    assert_response :ok
94
    assert_response :no_content
95 95
    assert_equal '', @response.body
96 96
    assert_nil IssueCategory.find_by_id(1)
97 97
  end
......
107 107
          :headers => credentials('jsmith')
108 108
      end
109 109
    end
110
    assert_response :ok
110
    assert_response :no_content
111 111
    assert_equal '', @response.body
112 112
    assert_nil IssueCategory.find_by_id(1)
113 113
  end
test/integration/api_test/issue_relations_test.rb (working copy)
77 77
      delete '/relations/2.xml', :headers => credentials('jsmith')
78 78
    end
79 79

  
80
    assert_response :ok
80
    assert_response :no_content
81 81
    assert_equal '', @response.body
82 82
    assert_nil IssueRelation.find_by_id(2)
83 83
  end
test/integration/api_test/issues_test.rb (working copy)
795 795
        :params => {:issue => {:subject => 'API update', :notes => 'A new note'}},
796 796
        :headers => credentials('jsmith')
797 797

  
798
      assert_response :ok
798
      assert_response :no_content
799 799
      assert_equal '', response.body
800 800
    end
801 801

  
......
819 819
    assert_difference('Issue.count', -1) do
820 820
      delete '/issues/6.xml', :headers => credentials('jsmith')
821 821

  
822
      assert_response :ok
822
      assert_response :no_content
823 823
      assert_equal '', response.body
824 824
    end
825 825
    assert_nil Issue.find_by_id(6)
......
829 829
    assert_difference('Issue.count', -1) do
830 830
      delete '/issues/6.json', :headers => credentials('jsmith')
831 831

  
832
      assert_response :ok
832
      assert_response :no_content
833 833
      assert_equal '', response.body
834 834
    end
835 835
    assert_nil Issue.find_by_id(6)
......
841 841
        :params => {:user_id => 3},
842 842
        :headers => credentials('jsmith')
843 843

  
844
      assert_response :ok
844
      assert_response :no_content
845 845
      assert_equal '', response.body
846 846
    end
847 847
    watcher = Watcher.order('id desc').first
......
855 855
    assert_difference 'Watcher.count', -1 do
856 856
      delete '/issues/1/watchers/3.xml', :headers => credentials('jsmith')
857 857

  
858
      assert_response :ok
858
      assert_response :no_content
859 859
      assert_equal '', response.body
860 860
    end
861 861
    assert_equal false, Issue.find(1).watched_by?(User.find(3))
......
972 972
                      :uploads => [{:token => token, :filename => 'test.txt',
973 973
                                    :content_type => 'text/plain'}]}},
974 974
        :headers => credentials('jsmith')
975
      assert_response :ok
975
      assert_response :no_content
976 976
      assert_equal '', @response.body
977 977
    end
978 978

  
test/integration/api_test/memberships_test.rb (working copy)
135 135
        :params => {:membership => {:user_id => 3, :role_ids => [1,2]}},
136 136
        :headers => credentials('jsmith')
137 137

  
138
      assert_response :ok
138
      assert_response :no_content
139 139
      assert_equal '', @response.body
140 140
    end
141 141
    member = Member.find(2)
......
156 156
    assert_difference 'Member.count', -1 do
157 157
      delete '/memberships/2.xml', :headers => credentials('jsmith')
158 158

  
159
      assert_response :ok
159
      assert_response :no_content
160 160
      assert_equal '', @response.body
161 161
    end
162 162
    assert_nil Member.find_by_id(2)
test/integration/api_test/projects_test.rb (working copy)
198 198
        :params => {:project => {:name => 'API update'}},
199 199
        :headers => credentials('jsmith')
200 200
    end
201
    assert_response :ok
201
    assert_response :no_content
202 202
    assert_equal '', @response.body
203
    assert_equal 'application/xml', @response.content_type
203
    assert_nil @response.content_type
204 204
    project = Project.find(2)
205 205
    assert_equal 'API update', project.name
206 206
  end
......
211 211
        :params => {:project => {:name => 'API update', :enabled_module_names => ['issue_tracking', 'news', 'time_tracking']}},
212 212
        :headers => credentials('admin')
213 213
    end
214
    assert_response :ok
214
    assert_response :no_content
215 215
    assert_equal '', @response.body
216 216
    project = Project.find(2)
217 217
    assert_equal ['issue_tracking', 'news', 'time_tracking'], project.enabled_module_names.sort
......
223 223
        :params => {:project => {:name => 'API update', :tracker_ids => [1, 3]}},
224 224
        :headers => credentials('admin')
225 225
    end
226
    assert_response :ok
226
    assert_response :no_content
227 227
    assert_equal '', @response.body
228 228
    project = Project.find(2)
229 229
    assert_equal [1, 3], project.trackers.map(&:id).sort
......
245 245
    assert_difference('Project.count',-1) do
246 246
      delete '/projects/2.xml', :headers => credentials('admin')
247 247
    end
248
    assert_response :ok
248
    assert_response :no_content
249 249
    assert_equal '', @response.body
250 250
    assert_nil Project.find_by_id(2)
251 251
  end
test/integration/api_test/time_entries_test.rb (working copy)
135 135
        :params => {:time_entry => {:comments => 'API Update'}},
136 136
        :headers => credentials('jsmith')
137 137
    end
138
    assert_response :ok
138
    assert_response :no_content
139 139
    assert_equal '', @response.body
140 140
    assert_equal 'API Update', TimeEntry.find(2).comments
141 141
  end
......
164 164
    assert_difference 'TimeEntry.count', -1 do
165 165
      delete '/time_entries/2.xml', :headers => credentials('jsmith')
166 166
    end
167
    assert_response :ok
167
    assert_response :no_content
168 168
    assert_equal '', @response.body
169 169
    assert_nil TimeEntry.find_by_id(2)
170 170
  end
test/integration/api_test/users_test.rb (working copy)
256 256
    assert_equal 'jsmith@somenet.foo', user.mail
257 257
    assert !user.admin?
258 258

  
259
    assert_response :ok
259
    assert_response :no_content
260 260
    assert_equal '', @response.body
261 261
  end
262 262

  
......
279 279
    assert_equal 'jsmith@somenet.foo', user.mail
280 280
    assert !user.admin?
281 281

  
282
    assert_response :ok
282
    assert_response :no_content
283 283
    assert_equal '', @response.body
284 284
  end
285 285

  
......
325 325
      delete '/users/2.xml', :headers => credentials('admin')
326 326
    end
327 327

  
328
    assert_response :ok
328
    assert_response :no_content
329 329
    assert_equal '', @response.body
330 330
  end
331 331

  
......
334 334
      delete '/users/2.json', :headers => credentials('admin')
335 335
    end
336 336

  
337
    assert_response :ok
337
    assert_response :no_content
338 338
    assert_equal '', @response.body
339 339
  end
340 340
end
test/integration/api_test/versions_test.rb (working copy)
122 122
      :params => {:version => {:name => 'API update'}},
123 123
      :headers => credentials('jsmith')
124 124

  
125
    assert_response :ok
125
    assert_response :no_content
126 126
    assert_equal '', @response.body
127 127
    assert_equal 'API update', Version.find(2).name
128 128
  end
......
132 132
      delete '/versions/3.xml', :headers => credentials('jsmith')
133 133
    end
134 134

  
135
    assert_response :ok
135
    assert_response :no_content
136 136
    assert_equal '', @response.body
137 137
    assert_nil Version.find_by_id(3)
138 138
  end
test/integration/api_test/wiki_pages_test.rb (working copy)
106 106
        put '/projects/ecookbook/wiki/CookBook_documentation.xml',
107 107
          :params => {:wiki_page => {:text => 'New content from API', :comments => 'API update'}},
108 108
          :headers => credentials('jsmith')
109
        assert_response 200
109
        assert_response :no_content
110 110
      end
111 111
    end
112 112

  
......
123 123
        put '/projects/ecookbook/wiki/CookBook_documentation.xml',
124 124
          :params => {:wiki_page => {:text => 'New content from API', :comments => 'API update', :version => '3'}},
125 125
          :headers => credentials('jsmith')
126
        assert_response 200
126
        assert_response :no_content
127 127
      end
128 128
    end
129 129

  
......
201 201
  test "DELETE /projects/:project_id/wiki/:title.xml should destroy the page" do
202 202
    assert_difference 'WikiPage.count', -1 do
203 203
      delete '/projects/ecookbook/wiki/CookBook_documentation.xml', :headers => credentials('jsmith')
204
      assert_response 200
204
      assert_response :no_content
205 205
    end
206 206

  
207 207
    assert_nil WikiPage.find_by_id(1)