Skip to content
Merged
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/topics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def set_topic

def scope
@scope ||= if Current.user.is_admin?
Topic.all
Topic.includes(:provider).all
elsif current_provider.present?
current_provider.topics
else
Expand Down
14 changes: 14 additions & 0 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: tags
#
# id :bigint not null, primary key
# name :string
# taggings_count :integer default(0)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_tags_on_name (name) UNIQUE
#
class Tag < ActsAsTaggableOn::Tag
has_many :tag_cognates, dependent: :destroy
has_many :cognates, through: :tag_cognates
Expand Down
2 changes: 2 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
language_id: Language.find_by(name: "english").id,
provider_id: Provider.find_by(name: "Provided by the government").id,
uid: "d290f1ee-6c54-4b01-90e6-d701748f0851",
published_at: Time.now - 1.day,
state: :active,
},
{
Expand All @@ -50,6 +51,7 @@
language_id: Language.find_by(name: "spanish").id,
provider_id: Provider.find_by(name: "Provided by the government").id,
uid: "d290f1ee-6c54-4b01-90e6-d701748f0852",
published_at: Time.now - 1.day,
state: :archived,
},
].each do |topic|
Expand Down
21 changes: 21 additions & 0 deletions spec/factories/tag_cognates.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# == Schema Information
#
# Table name: tag_cognates
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# cognate_id :bigint
# tag_id :bigint
#
# Indexes
#
# index_tag_cognates_on_cognate_id (cognate_id)
# index_tag_cognates_on_tag_id (tag_id)
# index_tag_cognates_on_tag_id_and_cognate_id (tag_id,cognate_id) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (cognate_id => tags.id)
# fk_rails_... (tag_id => tags.id)
#
FactoryBot.define do
factory :tag_cognate do
association :tag
Expand Down
14 changes: 14 additions & 0 deletions spec/factories/tags.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: tags
#
# id :bigint not null, primary key
# name :string
# taggings_count :integer default(0)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_tags_on_name (name) UNIQUE
#
FactoryBot.define do
factory :tag do
name { Faker::ProgrammingLanguage.name }
Expand Down
21 changes: 21 additions & 0 deletions spec/models/tag_cognate_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# == Schema Information
#
# Table name: tag_cognates
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# cognate_id :bigint
# tag_id :bigint
#
# Indexes
#
# index_tag_cognates_on_cognate_id (cognate_id)
# index_tag_cognates_on_tag_id (tag_id)
# index_tag_cognates_on_tag_id_and_cognate_id (tag_id,cognate_id) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (cognate_id => tags.id)
# fk_rails_... (tag_id => tags.id)
#
require "rails_helper"

RSpec.describe TagCognate, type: :model do
Expand Down
14 changes: 14 additions & 0 deletions spec/models/tag_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: tags
#
# id :bigint not null, primary key
# name :string
# taggings_count :integer default(0)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_tags_on_name (name) UNIQUE
#
require "rails_helper"

RSpec.describe Tag, type: :model do
Expand Down