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:
30
spec/components/moderation/users/index_component_spec.rb
Normal file
30
spec/components/moderation/users/index_component_spec.rb
Normal 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
|
||||
Reference in New Issue
Block a user