2017-05-24 13:50:20 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe "Discobot Certificate" do
|
|
|
|
let(:user) { Fabricate(:user, name: 'Jeff Atwood') }
|
|
|
|
|
|
|
|
describe 'when viewing the certificate' do
|
2017-05-26 13:00:17 +08:00
|
|
|
it 'should return the right text' do
|
|
|
|
params = {
|
|
|
|
date: Time.zone.now.strftime("%b %d %Y"),
|
|
|
|
user_id: user.id
|
|
|
|
}
|
|
|
|
|
|
|
|
stub_request(:get, /letter_avatar_proxy/).to_return(status: 200)
|
|
|
|
|
|
|
|
stub_request(:get, "http://test.localhost//images/d-logo-sketch-small.png")
|
|
|
|
.to_return(status: 200)
|
|
|
|
|
2017-08-31 12:06:56 +08:00
|
|
|
get '/discobot/certificate.svg', params: params
|
2017-05-26 13:00:17 +08:00
|
|
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
end
|
|
|
|
|
2017-05-24 13:50:20 +08:00
|
|
|
describe 'when params are missing' do
|
|
|
|
it "should raise the right errors" do
|
|
|
|
params = {
|
|
|
|
date: Time.zone.now.strftime("%b %d %Y"),
|
|
|
|
user_id: user.id
|
|
|
|
}
|
|
|
|
|
|
|
|
params.each do |key, _|
|
2017-08-31 12:06:56 +08:00
|
|
|
expect { get '/discobot/certificate.svg', params: params.except(key) }
|
2017-05-24 13:50:20 +08:00
|
|
|
.to raise_error(Discourse::InvalidParameters)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|