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

Commit

Permalink
fix-destroy-emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
masarakki committed Apr 16, 2018
1 parent d4ec182 commit 3fad6e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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

0 comments on commit 3fad6e1

Please sign in to comment.