blob: a8d96948caebad57d6d9654509c9ea162420841d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
require 'rails_helper'
describe Admin::CustomEmojisController do
render_views
let(:user) { Fabricate(:user, admin: true) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
subject { get :index }
before do
Fabricate(:custom_emoji)
end
it 'renders index page' do
expect(subject).to have_http_status 200
expect(subject).to render_template :index
end
end
describe 'GET #new' do
subject { get :new }
it 'renders new page' do
expect(subject).to have_http_status 200
expect(subject).to render_template :new
end
end
describe 'POST #create' do
subject { post :create, params: { custom_emoji: params } }
let(:image) { fixture_file_upload(Rails.root.join('spec', 'fixtures', 'files', 'emojo.png'), 'image/png') }
context 'when parameter is valid' do
let(:params) { { shortcode: 'test', image: image } }
it 'creates custom emoji' do
expect { subject }.to change { CustomEmoji.count }.by(1)
end
end
context 'when parameter is invalid' do
let(:params) { { shortcode: 't', image: image } }
it 'renders new' do
expect(subject).to render_template :new
end
end
end
end
|