UX: show if webhook is disabled (#7217)

+ show in staff logs when webhook is created/updated/destroyed
This commit is contained in:
Maja Komel
2019-03-21 16:13:09 +01:00
committed by Régis Hanol
parent bfcbc4d2d6
commit 34730a0b16
9 changed files with 75 additions and 5 deletions

View File

@ -34,6 +34,7 @@ describe Admin::WebHooksController do
json = ::JSON.parse(response.body)
expect(json["web_hook"]["payload_url"]).to eq("https://meta.discourse.org/")
expect(UserHistory.where(acting_user_id: admin.id, action: UserHistory.actions[:web_hook_create]).count).to eq(1)
end
it 'returns error when field is not filled correctly' do
@ -57,6 +58,30 @@ describe Admin::WebHooksController do
end
end
describe '#update' do
it "logs webhook update" do
put "/admin/api/web_hooks/#{web_hook.id}.json", params: {
web_hook: { active: false, payload_url: "https://test.com" }
}
expect(response.status).to eq(200)
expect(UserHistory.where(acting_user_id: admin.id,
action: UserHistory.actions[:web_hook_update],
new_value: "payload_url: https://test.com, active: false").exists?).to eq(true)
end
end
describe '#destroy' do
it "logs webhook destroy" do
delete "/admin/api/web_hooks/#{web_hook.id}.json", params: {
web_hook: { active: false, payload_url: "https://test.com" }
}
expect(response.status).to eq(200)
expect(UserHistory.where(acting_user_id: admin.id, action: UserHistory.actions[:web_hook_destroy]).exists?).to eq(true)
end
end
describe '#ping' do
it 'enqueues the ping event' do
expect do