Move users moderation index view to a component

This way it's easier to change the logic and write tests for it.
This commit is contained in:
Javi Martín
2021-12-30 13:21:02 +01:00
parent a31e73bf23
commit e9d9789c25
4 changed files with 85 additions and 47 deletions

View File

@@ -0,0 +1,30 @@
require "rails_helper"
describe Moderation::Users::IndexComponent, controller: Moderation::UsersController do
describe "actions or status" do
let(:component) { Moderation::Users::IndexComponent.new(User.with_hidden.page(1)) }
it "shows actions to block or hide users" do
create(:user)
render_inline component
page.find("table") do |table|
expect(table).to have_button "Hide"
expect(table).to have_button "Block"
expect(table).not_to have_content "Blocked"
end
end
it "shows 'blocked' for hidden users" do
create(:user, :hidden)
render_inline component
page.find("table") do |table|
expect(table).to have_content "Blocked"
expect(table).not_to have_button
end
end
end
end