forked from e621ng/e621ng
[NewsUpdates] Enable API endpoint for index
Also cleaned up some auto-correctable style issues.
This commit is contained in:
parent
af0036db6b
commit
727df848f7
@ -617,7 +617,6 @@ Layout/SpaceInsideHashLiteralBraces:
|
||||
- 'test/functional/maintenance/user/login_reminders_controller_test.rb'
|
||||
- 'test/functional/maintenance/user/password_resets_controller_test.rb'
|
||||
- 'test/functional/meta_searches_controller_test.rb'
|
||||
- 'test/functional/news_updates_controller_test.rb'
|
||||
- 'test/functional/note_versions_controller_test.rb'
|
||||
- 'test/functional/notes_controller_test.rb'
|
||||
- 'test/functional/pool_elements_controller_test.rb'
|
||||
@ -1093,7 +1092,6 @@ Rails/ActionOrder:
|
||||
- 'app/controllers/maintenance/user/password_resets_controller.rb'
|
||||
- 'app/controllers/mascots_controller.rb'
|
||||
- 'app/controllers/moderator/post/disapprovals_controller.rb'
|
||||
- 'app/controllers/news_updates_controller.rb'
|
||||
- 'app/controllers/pools_controller.rb'
|
||||
- 'app/controllers/post_flags_controller.rb'
|
||||
- 'app/controllers/post_replacements_controller.rb'
|
||||
@ -1630,7 +1628,6 @@ Style/HashSyntax:
|
||||
- 'app/controllers/maintenance/user/email_changes_controller.rb'
|
||||
- 'app/controllers/maintenance/user/email_notifications_controller.rb'
|
||||
- 'app/controllers/maintenance/user/password_resets_controller.rb'
|
||||
- 'app/controllers/news_updates_controller.rb'
|
||||
- 'app/controllers/note_previews_controller.rb'
|
||||
- 'app/controllers/notes_controller.rb'
|
||||
- 'app/controllers/pool_elements_controller.rb'
|
||||
@ -1809,7 +1806,6 @@ Style/HashSyntax:
|
||||
- 'test/functional/maintenance/user/dmail_filters_controller_test.rb'
|
||||
- 'test/functional/maintenance/user/login_reminders_controller_test.rb'
|
||||
- 'test/functional/maintenance/user/password_resets_controller_test.rb'
|
||||
- 'test/functional/news_updates_controller_test.rb'
|
||||
- 'test/functional/note_versions_controller_test.rb'
|
||||
- 'test/functional/notes_controller_test.rb'
|
||||
- 'test/functional/pool_elements_controller_test.rb'
|
||||
@ -2653,7 +2649,6 @@ Style/SymbolArray:
|
||||
# AllowedMethods: define_method, mail, respond_to
|
||||
Style/SymbolProc:
|
||||
Exclude:
|
||||
- 'app/controllers/news_updates_controller.rb'
|
||||
- 'app/controllers/pools_controller.rb'
|
||||
- 'app/controllers/posts_controller.rb'
|
||||
- 'app/logical/post_sets/base.rb'
|
||||
|
@ -3,39 +3,38 @@
|
||||
class NewsUpdatesController < ApplicationController
|
||||
before_action :admin_only, except: [:index]
|
||||
respond_to :html
|
||||
respond_to :json, only: %i[index]
|
||||
|
||||
def index
|
||||
@news_updates = NewsUpdate.includes(:creator).order("id desc").paginate(params[:page], :limit => params[:limit])
|
||||
@news_updates = NewsUpdate.includes(:creator).order("id desc").paginate(params[:page], limit: params[:limit])
|
||||
respond_with(@news_updates)
|
||||
end
|
||||
|
||||
def edit
|
||||
@news_update = NewsUpdate.find(params[:id])
|
||||
respond_with(@news_update)
|
||||
end
|
||||
|
||||
def update
|
||||
@news_update = NewsUpdate.find(params[:id])
|
||||
@news_update.update(news_update_params)
|
||||
respond_with(@news_update, :location => news_updates_path)
|
||||
end
|
||||
|
||||
def new
|
||||
@news_update = NewsUpdate.new
|
||||
respond_with(@news_update)
|
||||
end
|
||||
|
||||
def edit
|
||||
@news_update = NewsUpdate.find(params[:id])
|
||||
respond_with(@news_update)
|
||||
end
|
||||
|
||||
def create
|
||||
@news_update = NewsUpdate.create(news_update_params)
|
||||
respond_with(@news_update, :location => news_updates_path)
|
||||
respond_with(@news_update, location: news_updates_path)
|
||||
end
|
||||
|
||||
def update
|
||||
@news_update = NewsUpdate.find(params[:id])
|
||||
@news_update.update(news_update_params)
|
||||
respond_with(@news_update, location: news_updates_path)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@news_update = NewsUpdate.find(params[:id])
|
||||
@news_update.destroy
|
||||
respond_with(@news_update) do |format|
|
||||
format.js
|
||||
end
|
||||
respond_with(@news_update, &:js)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -34,7 +34,7 @@ class NewsUpdatesControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
context "update action" do
|
||||
should "work" do
|
||||
put_auth news_update_path(@news_update), @admin, params: {:news_update => {:message => "zzz"}}
|
||||
put_auth news_update_path(@news_update), @admin, params: { news_update: { message: "zzz" } }
|
||||
assert_redirected_to(news_updates_path)
|
||||
end
|
||||
end
|
||||
@ -42,7 +42,7 @@ class NewsUpdatesControllerTest < ActionDispatch::IntegrationTest
|
||||
context "create action" do
|
||||
should "work" do
|
||||
assert_difference("NewsUpdate.count") do
|
||||
post_auth news_updates_path, @admin, params: {:news_update => {:message => "zzz"}}
|
||||
post_auth news_updates_path, @admin, params: { news_update: { message: "zzz" } }
|
||||
end
|
||||
assert_redirected_to(news_updates_path)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user