Skip to content
代码片段 群组 项目
提交 87ff28cf 编辑于 作者: Ethan Urie's avatar Ethan Urie
浏览文件

Add request specs

上级 a57b001b
No related branches found
No related tags found
无相关合并请求
...@@ -74,4 +74,24 @@ ...@@ -74,4 +74,24 @@
expect { request }.to change { user.reload.access_locked? }.from(true).to(false) expect { request }.to change { user.reload.access_locked? }.from(true).to(false)
end end
end end
describe 'PUT #trust' do
subject(:request) { put trust_admin_user_path(user) }
it 'trusts the user' do
expect { request }.to change { user.reload.trusted? }.from(false).to(true)
end
end
describe 'PUT #untrust' do
before do
user.custom_attributes.create!(key: UserCustomAttribute::TRUSTED_BY, value: "placeholder")
end
subject(:request) { put untrust_admin_user_path(user) }
it 'trusts the user' do
expect { request }.to change { user.reload.trusted? }.from(true).to(false)
end
end
end end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Users::TrustService, feature_category: :user_management do
let_it_be(:current_user) { create(:admin) }
subject(:service) { described_class.new(current_user) }
describe '#execute' do
let(:user) { create(:user) }
subject(:operation) { service.execute(user) }
it 'updates the custom attributes', :aggregate_failures do
expect(user.custom_attributes).to be_empty
operation
user.reload
expect(user.custom_attributes.by_key(UserCustomAttribute::TRUSTED_BY)).to be_present
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Users::UntrustService, feature_category: :user_management do
let_it_be(:current_user) { create(:admin) }
subject(:service) { described_class.new(current_user) }
describe '#execute' do
let(:user) { create(:user) }
subject(:operation) { service.execute(user) }
before do
UserCustomAttribute.upsert_custom_attributes(
[{
user_id: user.id,
key: :allow_possible_spam,
value: 'not important'
}]
)
end
it 'updates the custom attributes', :aggregate_failures do
expect(user.custom_attributes.by_key(UserCustomAttribute::TRUSTED_BY)).to be_present
operation
user.reload
expect(user.custom_attributes).to be_empty
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册