プロジェクト

全般

プロフィール

Vote #73557

完了

REST API for News

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
REST API_32
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
32
version_id:
127
issue_org_id:
13468
author_id:
33780
assigned_to_id:
332
comments:
19
status_id:
5
tracker_id:
3
plus1:
2
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

Some small changes for supporting news creation over REST.


journals

--------------------------------------------------------------------------------
+1
--------------------------------------------------------------------------------
Hi, is this patch planned to be merged in an upcoming release ?
This would be great as I have to make a few dozen announcements each month on some of the projects I manage with Redmine. This is really tedious without automation.
--------------------------------------------------------------------------------
I made a patch with small changes and tests to the C. X.'s patch.
I'm looking forward to using this feature in future Redmine.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
It looks a bit awkward to me to implement POST only without implementing GET, PUT, and DELETE. I think that GET should be implemented at least.

With the current patch implemented, users can create news but they don't have the means to retrieve the news using an id.
--------------------------------------------------------------------------------
Go MAEDA wrote:
> It looks a bit awkward to me to implement POST only without implementing GET, PUT, and DELETE. I think that GET should be implemented at least.
>

Certainly, that is more beautiful as an API design.
I made a patch so that POST, GET, DELETE and PUT functions can be added gradually.

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
+1, Takaki's patches look good to me.
--------------------------------------------------------------------------------
Committed the patches. Thank you for your contribution. And vzvu 3k6k, thank you for reviewing the patches. Your review is very helpful to me.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
@Redmine::ApiTest::NewsTest#test_GET_/news/:id.xml@ fails if config.time_zone is set.

Set config.time_zone in config/additional_environment.rb.
<pre>
config.time_zone = 'Tokyo'
</pre>

The tests suppose that time in API response is always in UTC, but it varies depending on the value of config.time_zone is set.
<pre>
$ RAILS_ENV=test bundle exec rake test TEST=test/integration/api_test/news_test.rb
Run options: --seed 35340

# Running:

...................F

Failure:
Redmine::ApiTest::NewsTest#test_GET_/news/:id.xml [test/integration/api_test/news_test.rb:69]:
<(?-mix:^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$)> expected but was
<2006-07-20T05:40:26+09:00>..
Expected 0 to be >= 1.

bin/rails test test/integration/api_test/news_test.rb:65

...

Finished in 1.647332s, 13.9620 runs/s, 75.2732 assertions/s.
23 runs, 124 assertions, 1 failures, 0 errors, 0 skips
</pre>

The following patch will solve it.
<pre><code class="diff">
diff --git a/test/integration/api_test/news_test.rb b/test/integration/api_test/news_test.rb
index a6ca416a8..a7fccf9b6 100644
--- a/test/integration/api_test/news_test.rb
+++ b/test/integration/api_test/news_test.rb
@@ -73,8 +73,7 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
assert_select 'title', 'eCookbook first release !'
assert_select 'summary', 'First version was released...'
assert_select 'description', "eCookbook 1.0 has been released.\n\nVisit http://ecookbook.somenet.foo/"
- iso_date = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/
- assert_select 'news>created_on', :text => iso_date
+ assert_select 'created_on', News.find(1).created_on.iso8601
end
end

</code></pre>
--------------------------------------------------------------------------------
Yuichi HARADA wrote:
> @Redmine::ApiTest::NewsTest#test_GET_/news/:id.xml@ fails if config.time_zone is set.

Committed the fix in r18445. Thank you for reporting and fixing it.
--------------------------------------------------------------------------------
Sorry, I should have run tests locally before commenting.
Thanks for fixing.
--------------------------------------------------------------------------------
The test fails due to a missing fixture.

<pre>
$ RAILS_ENV=test bin/rake db:reset
$ bin/rails test test/integration/api_test/news_test.rb:88
Run options: --seed 61590

# Running:

E

Error:
Redmine::ApiTest::NewsTest#test_GET_/news/:id.xml_with_attachments:
NoMethodError: undefined method `container=' for nil:NilClass
Did you mean? concern
test/integration/api_test/news_test.rb:91:in `block in <class:NewsTest>'
</pre>

It can be fixed with the following patch.

<pre><code class="diff">
Index: test/integration/api_test/news_test.rb
===================================================================
--- test/integration/api_test/news_test.rb (リビジョン 18453)
+++ test/integration/api_test/news_test.rb (作業コピー)
@@ -28,7 +28,8 @@
:members,
:enabled_modules,
:news,
- :comments
+ :comments,
+ :attachments

test "GET /news.xml should return news" do
get '/news.xml'
</code></pre>
--------------------------------------------------------------------------------
Go MAEDA wrote:
> The test fails due to a missing fixture.

Committed in r18455.

--------------------------------------------------------------------------------


related_issues

relates,Closed,26653,REST API - Add full CRUD support for News

Admin Redmine さんが3年以上前に更新

  • カテゴリREST API_32 にセット
  • 対象バージョン4.1.0_127 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0