diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 51d6b2a9..3da8c072 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -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 diff --git a/app/models/tag.rb b/app/models/tag.rb index 157eb0d6..480da27a 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -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 diff --git a/db/seeds.rb b/db/seeds.rb index c9915b27..3a43a09b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -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, }, { @@ -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| diff --git a/spec/factories/tag_cognates.rb b/spec/factories/tag_cognates.rb index 1dd4338e..4b0b097e 100644 --- a/spec/factories/tag_cognates.rb +++ b/spec/factories/tag_cognates.rb @@ -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 diff --git a/spec/factories/tags.rb b/spec/factories/tags.rb index 92b8b491..a7031645 100644 --- a/spec/factories/tags.rb +++ b/spec/factories/tags.rb @@ -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 } diff --git a/spec/models/tag_cognate_spec.rb b/spec/models/tag_cognate_spec.rb index 886bdb3a..922869bf 100644 --- a/spec/models/tag_cognate_spec.rb +++ b/spec/models/tag_cognate_spec.rb @@ -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 diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 9f5eda38..2fec3b34 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -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