2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2013-08-08 04:04:12 +08:00
|
|
|
|
|
|
|
describe Admin::StaffActionLogsController do
|
|
|
|
it "is a subclass of AdminController" do
|
2015-01-10 01:04:02 +08:00
|
|
|
expect(Admin::StaffActionLogsController < Admin::AdminController).to eq(true)
|
2013-08-08 04:04:12 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
let!(:user) { log_in(:admin) }
|
|
|
|
|
|
|
|
context '.index' do
|
2017-04-12 22:52:52 +08:00
|
|
|
|
|
|
|
it 'works' do
|
2013-08-08 04:04:12 +08:00
|
|
|
xhr :get, :index
|
2017-04-12 22:52:52 +08:00
|
|
|
expect(response).to be_success
|
|
|
|
expect(::JSON.parse(response.body)).to be_a(Array)
|
2013-08-08 04:04:12 +08:00
|
|
|
end
|
2017-04-12 22:52:52 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
context '.diff' do
|
|
|
|
it 'can generate diffs for theme changes' do
|
|
|
|
theme = Theme.new(user_id: -1, name: 'bob')
|
2017-05-03 04:01:01 +08:00
|
|
|
theme.set_field(target: :mobile, name: :scss, value: 'body {.up}')
|
|
|
|
theme.set_field(target: :common, name: :scss, value: 'omit-dupe')
|
2017-04-12 22:52:52 +08:00
|
|
|
|
|
|
|
original_json = ThemeSerializer.new(theme, root: false).to_json
|
|
|
|
|
2017-05-03 04:01:01 +08:00
|
|
|
theme.set_field(target: :mobile, name: :scss, value: 'body {.down}')
|
2017-04-12 22:52:52 +08:00
|
|
|
|
|
|
|
record = StaffActionLogger.new(Discourse.system_user)
|
|
|
|
.log_theme_change(original_json, theme)
|
|
|
|
|
|
|
|
xhr :get, :diff, id: record.id
|
|
|
|
expect(response).to be_success
|
2013-08-08 04:04:12 +08:00
|
|
|
|
2017-04-12 22:52:52 +08:00
|
|
|
parsed = JSON.parse(response.body)
|
|
|
|
expect(parsed["side_by_side"]).to include("up")
|
|
|
|
expect(parsed["side_by_side"]).to include("down")
|
2013-08-08 04:04:12 +08:00
|
|
|
|
2017-04-12 22:52:52 +08:00
|
|
|
expect(parsed["side_by_side"]).not_to include("omit-dupe")
|
2013-08-08 04:04:12 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|