Skip to content
This repository has been archived by the owner on May 16, 2019. It is now read-only.

fix-destroy-emoji #214

Open
wants to merge 1 commit into
base: friends.nico
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/api/v1/custom_emojis_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ def resource_params
end

def set_custom_emoji
@custom_emoji = CustomEmoji.find(params[:id])
@custom_emoji = CustomEmoji.local.find_by(shortcode: params[:id])
end
end
12 changes: 12 additions & 0 deletions spec/controllers/api/v1/custom_emojis_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,16 @@
expect(response).to have_http_status(:success)
end
end

describe 'DELETE #destroy' do
let(:user) { Fabricate(:user, admin: true) }
before { sign_in user }
let!(:custom_emoji) { Fabricate(:custom_emoji) }
subject { delete :destroy, params: { id: custom_emoji.shortcode } }
it { expect { subject }.to change { CustomEmoji.count }.by(-1) }
it do
subject
expect(response).to have_http_status(:success)
end
end
end