diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 544440624..26d5bd370 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -258,8 +258,8 @@ module ApplicationHelper simple_form_for(model, **options, &block) end - def table_for(*args, **options, &block) - table = TableBuilder.new(*args, **options, &block) + def table_for(...) + table = TableBuilder.new(...) render "table_builder/table", table: table end diff --git a/app/logical/pagination_extension.rb b/app/logical/pagination_extension.rb index 280e08398..5d5113e8c 100644 --- a/app/logical/pagination_extension.rb +++ b/app/logical/pagination_extension.rb @@ -13,10 +13,10 @@ module PaginationExtension @paginator_count = 1_000_000 end - if page =~ /\Ab(\d+)\z/i + if page.to_s =~ /\Ab(\d+)\z/i @paginator_mode = :sequential_before paginate_sequential_before($1, records_per_page) - elsif page =~ /\Aa(\d+)\z/i + elsif page.to_s =~ /\Aa(\d+)\z/i @paginator_mode = :sequential_after paginate_sequential_after($1, records_per_page) else diff --git a/app/logical/table_builder.rb b/app/logical/table_builder.rb index a17f0f618..df628cb0f 100644 --- a/app/logical/table_builder.rb +++ b/app/logical/table_builder.rb @@ -49,8 +49,8 @@ class TableBuilder yield self if block_given? end - def column(*args, **options, &block) - @columns << Column.new(*args, **options, &block) + def column(...) + @columns << Column.new(...) end def all_row_attributes(item, i) diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 4940cec16..6be562a47 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -25,7 +25,7 @@ class PostPresenter locals[:article_attrs] = { "id" => "post_#{post.id}", - "class" => preview_class(post, options).join(" ") + "class" => preview_class(post, **options).join(" ") }.merge(data_attributes(post)) locals[:link_target] = options[:link_target] || post diff --git a/app/views/artist_versions/_listing.html.erb b/app/views/artist_versions/_listing.html.erb index 49b081733..6e4d97ef5 100644 --- a/app/views/artist_versions/_listing.html.erb +++ b/app/views/artist_versions/_listing.html.erb @@ -1,6 +1,6 @@
- <%= table_for @artist_versions, {class: "striped autofit", width: "100%"} do |t| %> + <%= table_for @artist_versions, class: "striped autofit", width: "100%" do |t| %> <% t.column "Name", td: {class: "diff-body"} do |artist_version| %> <%= link_to artist_version.name, artist_path(artist_version.artist_id) %> <%= link_to "»", artist_versions_path(search: {artist_id: artist_version.artist_id}, anchor: "artist-version-#{artist_version.id}") %> diff --git a/app/views/artists/index.html.erb b/app/views/artists/index.html.erb index df32647bd..49f2577e1 100644 --- a/app/views/artists/index.html.erb +++ b/app/views/artists/index.html.erb @@ -4,7 +4,7 @@
<%= render "search" %> - <%= table_for @artists, {class: "striped autofit"} do |t| %> + <%= table_for @artists, class: "striped autofit" do |t| %> <% t.column "Name" do |artist| %> <%= link_to artist.name, artist, class: "tag-type-#{Tag.categories.artist}" %> <%= artist.tag.try(:post_count) || 0 %> diff --git a/app/views/bans/index.html.erb b/app/views/bans/index.html.erb index fe2c63e05..7795e9def 100644 --- a/app/views/bans/index.html.erb +++ b/app/views/bans/index.html.erb @@ -4,7 +4,7 @@ <%= render "search" %> - <%= table_for @bans, {class: "striped autofit"} do |t| %> + <%= table_for @bans, class: "striped autofit" do |t| %> <% t.column "Banned User" do |ban| %> <%= link_to_user(ban.user) %> <%= link_to "»", bans_path(search: search_params.merge(user_name: ban.user.name)) %> diff --git a/app/views/comment_votes/index.html.erb b/app/views/comment_votes/index.html.erb index 2f0884645..5151af561 100644 --- a/app/views/comment_votes/index.html.erb +++ b/app/views/comment_votes/index.html.erb @@ -12,7 +12,7 @@ <%= f.submit "Search" %> <% end %> - <%= table_for @comment_votes, {class: "striped autofit"} do |t| %> + <%= table_for @comment_votes, class: "striped autofit" do |t| %> <% t.column "Post" do |vote| %> <%= PostPresenter.preview(vote.comment.post, show_deleted: true) %> <% end %> diff --git a/app/views/delayed_jobs/index.html.erb b/app/views/delayed_jobs/index.html.erb index 00482f9f5..6c5cab416 100644 --- a/app/views/delayed_jobs/index.html.erb +++ b/app/views/delayed_jobs/index.html.erb @@ -2,7 +2,7 @@

Delayed Jobs

- <%= table_for @delayed_jobs, {class: "striped autofit"} do |t| %> + <%= table_for @delayed_jobs, class: "striped autofit" do |t| %> <% t.column :queue %> <% t.column "Name" do |job| %> <%= raw print_name(job) %> diff --git a/app/views/favorite_groups/index.html.erb b/app/views/favorite_groups/index.html.erb index c19d3ee2d..686b3a0ae 100644 --- a/app/views/favorite_groups/index.html.erb +++ b/app/views/favorite_groups/index.html.erb @@ -8,7 +8,7 @@ <% end %> <%= table_for @favorite_groups, width: "100%" do |t| %> - <% t.column "Name", {width: "60%"} do |favgroup| %> + <% t.column "Name", width: "60%" do |favgroup| %> <%= link_to favgroup.pretty_name, favorite_group_path(favgroup) %> <% if favgroup.post_count > CurrentUser.user.per_page %> <%= link_to "page #{favgroup.last_page}", favorite_group_path(favgroup, :page => favgroup.last_page), :class => "last-page" %> diff --git a/app/views/forum_post_votes/index.html.erb b/app/views/forum_post_votes/index.html.erb index 3c262f1e3..85fbb6ca3 100644 --- a/app/views/forum_post_votes/index.html.erb +++ b/app/views/forum_post_votes/index.html.erb @@ -10,7 +10,7 @@ <%= f.submit "Search" %> <% end %> - <%= table_for @forum_post_votes, {class: "striped autofit"} do |t| %> + <%= table_for @forum_post_votes, class: "striped autofit" do |t| %> <% t.column "Forum Post" do |forum_post_vote| %> <%= link_to "Forum ##{forum_post_vote.forum_post_id}", forum_post_vote.forum_post %> <%= link_to "»", forum_post_votes_path(search: { forum_post_id: forum_post_vote.forum_post_id }) %> diff --git a/app/views/ip_addresses/_index.html.erb b/app/views/ip_addresses/_index.html.erb index cb7179777..e6f68fab3 100644 --- a/app/views/ip_addresses/_index.html.erb +++ b/app/views/ip_addresses/_index.html.erb @@ -1,4 +1,4 @@ -<%= table_for @ip_addresses, {class: "striped autofit"} do |t| %> +<%= table_for @ip_addresses, class: "striped autofit" do |t| %> <% t.column "IP Address" do |ip| %> <%= link_to ip.ip_addr, ip_addresses_path(search: { ip_addr: ip.ip_addr }) %> <%= link_to "»", ip_addresses_path(search: { ip_addr: ip.ip_addr, group_by: "user" }) %> diff --git a/app/views/ip_addresses/_index_by_ip_addr.html.erb b/app/views/ip_addresses/_index_by_ip_addr.html.erb index 5c827a60d..f99a137b1 100644 --- a/app/views/ip_addresses/_index_by_ip_addr.html.erb +++ b/app/views/ip_addresses/_index_by_ip_addr.html.erb @@ -2,7 +2,7 @@ <%= link_to "Find all users associated with the top 10 IP addresses", ip_addresses_path(search: { ip_addr: @ip_addresses.map(&:to_s).take(10).join(" "), group_by: "user" }) %>

-<%= table_for @ip_addresses, {class: "striped autofit"} do |t| %> +<%= table_for @ip_addresses, class: "striped autofit" do |t| %> <% t.column "IP Address" do |ip| %> <%= link_to ip.to_s, ip_addresses_path(search: { ip_addr: ip.to_s }) %> <%= link_to "»", ip_addresses_path(search: { ip_addr: ip.to_s, group_by: "user" }) %> diff --git a/app/views/ip_addresses/_index_by_user.html.erb b/app/views/ip_addresses/_index_by_user.html.erb index 06f77959a..894852aa1 100644 --- a/app/views/ip_addresses/_index_by_user.html.erb +++ b/app/views/ip_addresses/_index_by_user.html.erb @@ -2,7 +2,7 @@ <%= link_to "Find all IP addresses associated with these users", ip_addresses_path(search: { user_id: @ip_addresses.map(&:user_id).join(" "), group_by: "ip_addr" }) %>

-<%= table_for @ip_addresses, {class: "striped autofit"} do |t| %> +<%= table_for @ip_addresses, class: "striped autofit" do |t| %> <% t.column "User" do |ip| %> <%= link_to_user ip.user %> <%= link_to "»", ip_addresses_path(search: { user_id: ip.user_id, group_by: "ip_addr" }) %> diff --git a/app/views/mod_actions/index.html.erb b/app/views/mod_actions/index.html.erb index dcad00d39..f5533704b 100644 --- a/app/views/mod_actions/index.html.erb +++ b/app/views/mod_actions/index.html.erb @@ -4,7 +4,7 @@ <%= render "search" %> - <%= table_for @mod_actions, {class: "striped autofit"} do |t| %> + <%= table_for @mod_actions, class: "striped autofit" do |t| %> <% t.column "Category" do |mod_action| %> <%= link_to mod_action.category.humanize, mod_actions_path(search: { category: mod_action.category_id }) %> <% end %> diff --git a/app/views/note_versions/_listing.html.erb b/app/views/note_versions/_listing.html.erb index 2bd4e0943..ae170ab6e 100644 --- a/app/views/note_versions/_listing.html.erb +++ b/app/views/note_versions/_listing.html.erb @@ -1,6 +1,6 @@
- <%= table_for @note_versions, {class: "striped autofit", width: "100%"} do |t| %> + <%= table_for @note_versions, class: "striped autofit", width: "100%" do |t| %> <% t.column "Post", width: "5%" do |note_version| %> <%= link_to note_version.post_id, post_path(note_version.post_id) %> <% if !params.dig(:search, :post_id).present? %> diff --git a/app/views/notes/index.html.erb b/app/views/notes/index.html.erb index 6b29a33bb..c52af8bdb 100644 --- a/app/views/notes/index.html.erb +++ b/app/views/notes/index.html.erb @@ -4,7 +4,7 @@

Notes

- <%= table_for @notes, {class: "striped autofit"} do |t| %> + <%= table_for @notes, class: "striped autofit" do |t| %> <% t.column "Post" do |note| %> <%= link_to note.post_id, note.post %> <% end %> diff --git a/app/views/pool_versions/_listing.html.erb b/app/views/pool_versions/_listing.html.erb index bf663495a..6dbf9e4ee 100644 --- a/app/views/pool_versions/_listing.html.erb +++ b/app/views/pool_versions/_listing.html.erb @@ -1,6 +1,6 @@
- <%= table_for @pool_versions, {class: "striped autofit", width: "100%"} do |t| %> + <%= table_for @pool_versions, class: "striped autofit", width: "100%" do |t| %> <% t.column column: "diff", width: "3%" do |pool_version| %> <%= link_to_if pool_version_show_diff(pool_version, params[:type]), "diff", diff_pool_version_path(pool_version.id) %> <% end %> diff --git a/app/views/post_disapprovals/index.html.erb b/app/views/post_disapprovals/index.html.erb index 84087cd22..9b3b23adf 100644 --- a/app/views/post_disapprovals/index.html.erb +++ b/app/views/post_disapprovals/index.html.erb @@ -13,7 +13,7 @@ <%= f.submit "Search" %> <% end %> - <%= table_for @post_disapprovals, {class: "striped autofit", width: "100%"} do |t| %> + <%= table_for @post_disapprovals, class: "striped autofit", width: "100%" do |t| %> <% t.column "Post" do |post_disapproval| %> <%= link_to "post ##{post_disapproval.post_id}", post_path(post_disapproval.post_id) %> <%= link_to "»", post_disapprovals_path(search: params[:search].merge(post_id: post_disapproval.post_id)) %> diff --git a/app/views/post_replacements/index.html.erb b/app/views/post_replacements/index.html.erb index e367cfdc8..b0dd09c87 100644 --- a/app/views/post_replacements/index.html.erb +++ b/app/views/post_replacements/index.html.erb @@ -10,7 +10,7 @@ <%= f.submit "Search" %> <% end %> - <%= table_for @post_replacements, {class: "striped autofit", width: "100%"} do |t| %> + <%= table_for @post_replacements, class: "striped autofit", width: "100%" do |t| %> <% t.column "Post", width: "1%" do |post_replacement| %> <%= PostPresenter.preview(post_replacement.post, show_deleted: true) %> <% end %> diff --git a/app/views/post_votes/index.html.erb b/app/views/post_votes/index.html.erb index 005bbdd0c..a9ba0be9e 100644 --- a/app/views/post_votes/index.html.erb +++ b/app/views/post_votes/index.html.erb @@ -8,7 +8,7 @@ <%= f.submit "Search" %> <% end %> - <%= table_for @post_votes, {class: "striped autofit"} do |t| %> + <%= table_for @post_votes, class: "striped autofit" do |t| %> <% t.column "Post" do |vote| %> <%= PostPresenter.preview(vote.post, show_deleted: true) %> <% end %> diff --git a/app/views/saved_searches/index.html.erb b/app/views/saved_searches/index.html.erb index 24a96f777..8195bf54b 100644 --- a/app/views/saved_searches/index.html.erb +++ b/app/views/saved_searches/index.html.erb @@ -14,7 +14,7 @@ <%= f.submit "Search" %> <% end %> - <%= table_for @saved_searches, {class: "striped autofit", width: "100%"} do |t| %> + <%= table_for @saved_searches, class: "striped autofit", width: "100%" do |t| %> <% t.column "Query", th: {"data-sort": "string"}, td: {class: "col-expand"} do |ss| %> <%= link_to ss.query, posts_path(tags: ss.query) %> <% end %> diff --git a/app/views/table_builder/_table.html.erb b/app/views/table_builder/_table.html.erb index 05f5a9f53..2cf2cfe1b 100644 --- a/app/views/table_builder/_table.html.erb +++ b/app/views/table_builder/_table.html.erb @@ -1,8 +1,8 @@ -<%= tag.table table.table_attributes do %> +<%= tag.table **table.table_attributes do %> <% table.columns.each do |column| %> - <%= tag.th column.header_attributes do %> + <%= tag.th **column.header_attributes do %> <%= column.name %> <% end %> <% end %> @@ -11,9 +11,9 @@ <% table.items.each_with_index do |item, i| %> - <%= tag.tr table.all_row_attributes(item, i) do %> + <%= tag.tr **table.all_row_attributes(item, i) do %> <% table.columns.each_with_index do |column, j| %> - <%= tag.td column.body_attributes do %> + <%= tag.td **column.body_attributes do %> <%= column.value(item, i, j) %> <% end %> <% end %> diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb index 8f2d2f621..8648b1466 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/tags/index.html.erb @@ -4,7 +4,7 @@
<%= render "search" %> - <%= table_for @tags, {class: "striped autofit"} do |t| %> + <%= table_for @tags, class: "striped autofit" do |t| %> <% t.column :post_count, name: "Count" %> <% t.column "Name", td: {class: "col-expand"} do |tag| %> <%= link_to_wiki "?", tag.name, class: tag_class(tag) %> diff --git a/app/views/uploads/index.html.erb b/app/views/uploads/index.html.erb index 5e6819585..55e75beb2 100644 --- a/app/views/uploads/index.html.erb +++ b/app/views/uploads/index.html.erb @@ -3,7 +3,7 @@ <%= render "uploads/search" %> <%= render "posts/partials/common/inline_blacklist" %> - <%= table_for @uploads, {class: "striped autofit", width: "100%"} do |t| %> + <%= table_for @uploads, class: "striped autofit", width: "100%" do |t| %> <% t.column "Upload" do |upload| %> <%= PostPresenter.preview(upload.post, tags: "user:#{upload.uploader.name}", show_deleted: true) %> <% end %> diff --git a/app/views/user_feedbacks/index.html.erb b/app/views/user_feedbacks/index.html.erb index 35a50e961..7fc9733b1 100644 --- a/app/views/user_feedbacks/index.html.erb +++ b/app/views/user_feedbacks/index.html.erb @@ -13,7 +13,7 @@ <%= f.submit "Search" %> <% end %> - <%= table_for @user_feedbacks, {class: "striped autofit"} do |t| %> + <%= table_for @user_feedbacks, class: "striped autofit" do |t| %> <% t.column "User" do |feedback| %> <%= link_to_user feedback.user %> <%= link_to "»", user_feedbacks_path(search: { user_name: feedback.user.name }) %> diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 4e43a48be..3da20f6b5 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -127,7 +127,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_redirected_to User.last assert_equal("xxx", User.last.name) assert_equal(User.last, User.last.authenticate_password("xxxxx1")) - assert_equal(nil, User.last.email_address) + assert_nil(User.last.email_address) assert_no_enqueued_emails end diff --git a/test/test_helper.rb b/test/test_helper.rb index 6fafbaa57..1305c401e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -89,25 +89,25 @@ class ActionDispatch::IntegrationTest mock_post_version_service! mock_pool_version_service! - def method_authenticated(method_name, url, user, options) + def method_authenticated(method_name, url, user, **options) post session_path, params: { name: user.name, password: user.password } - self.send(method_name, url, options) + send(method_name, url, **options) end - def get_auth(url, user, options = {}) - method_authenticated(:get, url, user, options) + def get_auth(url, user, **options) + method_authenticated(:get, url, user, **options) end - def post_auth(url, user, options = {}) - method_authenticated(:post, url, user, options) + def post_auth(url, user, **options) + method_authenticated(:post, url, user, **options) end - def put_auth(url, user, options = {}) - method_authenticated(:put, url, user, options) + def put_auth(url, user, **options) + method_authenticated(:put, url, user, **options) end - def delete_auth(url, user, options = {}) - method_authenticated(:delete, url, user, options) + def delete_auth(url, user, **options) + method_authenticated(:delete, url, user, **options) end def setup diff --git a/test/unit/post_disapproval_test.rb b/test/unit/post_disapproval_test.rb index 8def746e1..f16203e48 100644 --- a/test/unit/post_disapproval_test.rb +++ b/test/unit/post_disapproval_test.rb @@ -21,7 +21,7 @@ class PostDisapprovalTest < ActiveSupport::TestCase should "not allow blank messages" do @post_disapproval = create(:post_disapproval, post: @post_1, message: "") - assert_equal(nil, @post_disapproval.message) + assert_nil(@post_disapproval.message) end context "made by alice" do