2015-10-11 05:41:23 -04:00
|
|
|
require "rails_helper"
|
2014-12-22 19:12:26 -05:00
|
|
|
|
|
|
|
describe Admin::EmojisController do
|
|
|
|
|
|
|
|
let(:custom_emoji) do
|
|
|
|
Emoji.new("/path/to/hello").tap do |e|
|
|
|
|
e.name = "hello"
|
|
|
|
e.url = "/url/to/hello.png"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-05-20 10:45:31 -04:00
|
|
|
let(:custom_emoji2) do
|
|
|
|
Emoji.new("/path/to/hello2").tap do |e|
|
|
|
|
e.name = "hello2"
|
|
|
|
e.url = "/url/to/hello2.png"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-12-22 19:12:26 -05:00
|
|
|
context "when logged in" do
|
|
|
|
let!(:user) { log_in(:admin) }
|
|
|
|
|
2015-05-20 10:45:31 -04:00
|
|
|
context ".index" do
|
2014-12-22 19:12:26 -05:00
|
|
|
it "returns a list of custom emojis" do
|
|
|
|
Emoji.expects(:custom).returns([custom_emoji])
|
2017-08-31 00:06:56 -04:00
|
|
|
get :index, format: :json
|
2015-01-09 12:04:02 -05:00
|
|
|
expect(response).to be_success
|
2014-12-22 19:12:26 -05:00
|
|
|
json = ::JSON.parse(response.body)
|
2015-05-20 10:45:31 -04:00
|
|
|
expect(json[0]["name"]).to eq(custom_emoji.name)
|
|
|
|
expect(json[0]["url"]).to eq(custom_emoji.url)
|
2014-12-22 19:12:26 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|