2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2015-08-19 05:15:46 +08:00
|
|
|
|
|
|
|
describe Admin::EmbeddableHostsController do
|
|
|
|
it "is a subclass of AdminController" do
|
|
|
|
expect(Admin::EmbeddableHostsController < Admin::AdminController).to eq(true)
|
|
|
|
end
|
2019-03-30 00:05:51 +08:00
|
|
|
|
|
|
|
context 'while logged in as an admin' do
|
|
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
let(:embeddable_host) { Fabricate(:embeddable_host) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#create' do
|
|
|
|
it "logs embeddable host create" do
|
|
|
|
post "/admin/embeddable_hosts.json", params: {
|
|
|
|
embeddable_host: { host: "test.com" }
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(UserHistory.where(acting_user_id: admin.id,
|
|
|
|
action: UserHistory.actions[:embeddable_host_create]).exists?).to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#update' do
|
2019-05-01 02:01:21 +08:00
|
|
|
xit "logs embeddable host update" do
|
2019-04-29 14:56:51 +08:00
|
|
|
category = Fabricate(:category)
|
2019-05-01 02:01:21 +08:00
|
|
|
|
2019-03-30 00:05:51 +08:00
|
|
|
put "/admin/embeddable_hosts/#{embeddable_host.id}.json", params: {
|
2019-04-29 14:56:51 +08:00
|
|
|
embeddable_host: { host: "test.com", class_name: "test-class", category_id: category.id }
|
2019-03-30 00:05:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
expect(response.status).to eq(200)
|
2019-04-29 13:19:05 +08:00
|
|
|
|
2019-04-29 14:56:51 +08:00
|
|
|
history_exists = UserHistory.where(
|
2019-04-29 13:19:05 +08:00
|
|
|
acting_user_id: admin.id,
|
|
|
|
action: UserHistory.actions[:embeddable_host_update],
|
2019-04-29 14:56:51 +08:00
|
|
|
new_value: "host: test.com, class_name: test-class, category_id: #{category.id}").exists?
|
|
|
|
|
|
|
|
expect(history_exists).to eq(true)
|
2019-04-29 13:19:05 +08:00
|
|
|
|
2019-03-30 00:05:51 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#destroy' do
|
|
|
|
it "logs embeddable host destroy" do
|
|
|
|
delete "/admin/embeddable_hosts/#{embeddable_host.id}.json", params: {}
|
|
|
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(UserHistory.where(acting_user_id: admin.id, action: UserHistory.actions[:embeddable_host_destroy]).exists?).to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-08-19 05:15:46 +08:00
|
|
|
end
|