|
|
@@ -4,8 +4,12 @@ require 'rails_helper' |
|
|
|
|
|
|
|
|
RSpec.describe 'Tags API', type: :request do |
|
|
RSpec.describe 'Tags API', type: :request do |
|
|
let!(:tn) { TagName.create!(name: 'spec_tag') } |
|
|
let!(:tn) { TagName.create!(name: 'spec_tag') } |
|
|
let!(:tag) { Tag.create!(tag_name: tn, category: 'general') } |
|
|
|
|
|
|
|
|
let!(:tag) { Tag.create!(tag_name: tn, category: :general) } |
|
|
let!(:alias_tn) { TagName.create!(name: 'unko', canonical: tn) } |
|
|
let!(:alias_tn) { TagName.create!(name: 'unko', canonical: tn) } |
|
|
|
|
|
let!(:post) { Post.create!(url: 'https://example.com/unkounkounko') } |
|
|
|
|
|
let!(:post_tag) { PostTag.create!(post:, tag:) } |
|
|
|
|
|
let!(:tn2) { TagName.create!(name: 'unknown') } |
|
|
|
|
|
let!(:tag2) { Tag.create!(tag_name: tn2, category: :general) } |
|
|
|
|
|
|
|
|
describe 'GET /tags' do |
|
|
describe 'GET /tags' do |
|
|
it 'returns tags with name' do |
|
|
it 'returns tags with name' do |
|
|
@@ -71,6 +75,7 @@ RSpec.describe 'Tags API', type: :request do |
|
|
expect(json.map { |t| t['name'] }).to include('spec_tag') |
|
|
expect(json.map { |t| t['name'] }).to include('spec_tag') |
|
|
t = json.find { |t| t['name'] == 'spec_tag' } |
|
|
t = json.find { |t| t['name'] == 'spec_tag' } |
|
|
expect(t['matched_alias']).to eq('unko') |
|
|
expect(t['matched_alias']).to eq('unko') |
|
|
|
|
|
expect(json.map { |t| t['name'] }).not_to include('unknown') |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|