2018-12-11 05:37:38 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2023-05-04 12:49:53 +09:00
|
|
|
RSpec.describe Admin::TagsController do
|
2018-12-11 05:37:38 +09:00
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
2022-07-05 09:41:40 +09:00
|
|
|
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin'))
|
2018-12-11 05:37:38 +09:00
|
|
|
end
|
|
|
|
|
2021-03-27 02:36:16 +09:00
|
|
|
describe 'GET #show' do
|
|
|
|
let!(:tag) { Fabricate(:tag) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
get :show, params: { id: tag.id }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns status 200' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
end
|
2023-10-17 00:20:28 +09:00
|
|
|
|
|
|
|
describe 'PUT #update' do
|
|
|
|
let!(:tag) { Fabricate(:tag, listable: false) }
|
|
|
|
|
|
|
|
context 'with valid params' do
|
|
|
|
it 'updates the tag' do
|
|
|
|
put :update, params: { id: tag.id, tag: { listable: '1' } }
|
|
|
|
|
|
|
|
expect(response).to redirect_to(admin_tag_path(tag.id))
|
|
|
|
expect(tag.reload).to be_listable
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with invalid params' do
|
|
|
|
it 'does not update the tag' do
|
|
|
|
put :update, params: { id: tag.id, tag: { name: 'cant-change-name' } }
|
|
|
|
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(response).to render_template(:show)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-12-11 05:37:38 +09:00
|
|
|
end
|