2018-12-10 21:37:38 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2023-05-04 05:49:53 +02:00
|
|
|
RSpec.describe Admin::TagsController do
|
2018-12-10 21:37:38 +01:00
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
2022-07-05 02:41:40 +02:00
|
|
|
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin'))
|
2018-12-10 21:37:38 +01:00
|
|
|
end
|
|
|
|
|
2021-03-26 18:36:16 +01: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-16 17:20:28 +02: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-10 21:37:38 +01:00
|
|
|
end
|