added 260907 version of worker toolkit

This commit is contained in:
2026-09-08 20:30:51 -04:00
parent cbd3f0f8ca
commit 97aca37663
1283 changed files with 142951 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
require "rails_helper"
require "cancan/matchers"
RSpec.describe Ability do
let!(:user) { create(:user) }
subject { Ability.new(user) }
context "for conditions" do
let!(:global_condition) { create(:condition) }
let!(:personal_condition) { create(:user_condition, user: user).condition }
let!(:another_user_condition) { create(:user_condition).condition }
let!(:popular_condition) { create(:condition, :personal) }
before { create_list(:user_condition, Flaredown.config.trackables_min_popularity, condition: popular_condition) }
context "index" do
it "allow to index personal condition" do
is_expected.to be_able_to(:index, personal_condition)
end
it "allow to index global conditions" do
is_expected.to be_able_to(:index, global_condition)
end
it "don't allow to index another user's personal condition" do
is_expected.not_to be_able_to(:index, another_user_condition)
end
end
context "show" do
it "allow to show global conditions" do
is_expected.to be_able_to(:show, global_condition)
end
it "allow to show personal conditions" do
is_expected.to be_able_to(:show, personal_condition)
end
it "allow to show popular conditions" do
is_expected.to be_able_to(:show, popular_condition)
end
it "allow to show another user's personal condition" do
is_expected.to be_able_to(:show, another_user_condition)
end
end
context "manage" do
it "allow to manage user's personal conditions" do
is_expected.to be_able_to(:manage, personal_condition)
end
it "don't allow to manage another user's personal conditions" do
is_expected.not_to be_able_to(:manage, another_user_condition)
end
end
context "create" do
let(:new_condition) { Condition.new(global: false) }
let(:new_global_condition) { Condition.new }
it "allow to create non-global conditions" do
is_expected.to be_able_to(:create, new_condition)
end
it "don't allow to create global conditions" do
is_expected.not_to be_able_to(:create, new_global_condition)
end
end
context "popular conditions" do
before { create_list(:user_condition, Flaredown.config.trackables_min_popularity, condition: popular_condition) }
let(:popular_condition_ids) { Ability.new(user).send(:popular_trackable_ids, "Condition") }
it { expect(popular_condition_ids).to eq([popular_condition.id]) }
end
end
end

View File

@@ -0,0 +1,61 @@
require "rails_helper"
require "cancan/matchers"
RSpec.describe Ability do
let!(:user) { create(:user) }
subject { Ability.new(user) }
context "for foods" do
let!(:global_food) { create(:food) }
let!(:personal_food) { create(:user_food, user: user).food }
let!(:another_user_food) { create(:user_food).food }
let!(:popular_food) { create(:food, :personal) }
before { create_list(:user_food, Flaredown.config.trackables_min_popularity, food: popular_food) }
context "index" do
it "allow to index personal food" do
is_expected.to be_able_to(:index, personal_food)
end
it "allow to index global food" do
is_expected.to be_able_to(:index, global_food)
end
it "don't allow to index another user's personal food" do
is_expected.not_to be_able_to(:index, another_user_food)
end
end
context "show" do
it "allow to show global food" do
is_expected.to be_able_to(:show, global_food)
end
it "allow to show personal food" do
is_expected.to be_able_to(:show, personal_food)
end
it "allow to show another user's personal food" do
is_expected.to be_able_to(:show, another_user_food)
end
end
context "manage" do
it "allow to manage user's personal food" do
is_expected.to be_able_to(:manage, personal_food)
end
it "don't allow to manage another user's personal food" do
is_expected.not_to be_able_to(:manage, another_user_food)
end
end
context "create" do
let(:new_food) { Food.new(global: false) }
let(:new_global_food) { Food.new }
it "allow to create non-global food" do
is_expected.to be_able_to(:create, new_food)
end
it "don't allow to create global food" do
is_expected.not_to be_able_to(:create, new_global_food)
end
end
end
end

View File

@@ -0,0 +1,72 @@
require "rails_helper"
require "cancan/matchers"
RSpec.describe Ability do
let!(:user) { create(:user) }
subject { Ability.new(user) }
context "for symptoms" do
let!(:global_symptom) { create(:symptom) }
let!(:personal_symptom) { create(:user_symptom, user: user).symptom }
let!(:another_user_symptom) { create(:user_symptom).symptom }
let!(:popular_symptom) { create(:symptom, :personal) }
before { create_list(:user_symptom, Flaredown.config.trackables_min_popularity, symptom: popular_symptom) }
context "index" do
it "allow to index personal symptom" do
is_expected.to be_able_to(:index, personal_symptom)
end
it "allow to index global symptoms" do
is_expected.to be_able_to(:index, global_symptom)
end
it "don't allow to index another user's personal symptom" do
is_expected.not_to be_able_to(:index, another_user_symptom)
end
end
context "show" do
it "allow to show global symptoms" do
is_expected.to be_able_to(:show, global_symptom)
end
it "allow to show personal symptoms" do
is_expected.to be_able_to(:show, personal_symptom)
end
it "allow to show popular symptoms" do
is_expected.to be_able_to(:show, popular_symptom)
end
it "allow to show another user's personal symptoms" do
is_expected.to be_able_to(:show, another_user_symptom)
end
end
context "manage" do
it "allow to manage user's personal symptoms" do
is_expected.to be_able_to(:manage, personal_symptom)
end
it "don't allow to manage another user's personal symptoms" do
is_expected.not_to be_able_to(:manage, another_user_symptom)
end
end
context "create" do
let(:new_symptom) { Symptom.new(global: false) }
let(:new_global_symptom) { Symptom.new }
it "allow to create non-global symptoms" do
is_expected.to be_able_to(:create, new_symptom)
end
it "don't allow to create global symptoms" do
is_expected.not_to be_able_to(:create, new_global_symptom)
end
end
context "popular symptoms" do
before { create_list(:user_symptom, Flaredown.config.trackables_min_popularity, symptom: popular_symptom) }
let(:popular_symptom_ids) { Ability.new(user).send(:popular_trackable_ids, "Symptom") }
it { expect(popular_symptom_ids).to eq([popular_symptom.id]) }
end
end
end

View File

@@ -0,0 +1,61 @@
require "rails_helper"
require "cancan/matchers"
RSpec.describe Ability do
let!(:user) { create(:user) }
subject { Ability.new(user) }
context "for tags" do
let!(:global_tag) { create(:tag) }
let!(:personal_tag) { create(:user_tag, user: user).tag }
let!(:another_user_tag) { create(:user_tag).tag }
let!(:popular_tag) { create(:tag, :personal) }
before { create_list(:user_tag, Flaredown.config.trackables_min_popularity, tag: popular_tag) }
context "index" do
it "allow to index personal tag" do
is_expected.to be_able_to(:index, personal_tag)
end
it "allow to index global tag" do
is_expected.to be_able_to(:index, global_tag)
end
it "don't allow to index another user's personal tag" do
is_expected.not_to be_able_to(:index, another_user_tag)
end
end
context "show" do
it "allow to show global tags" do
is_expected.to be_able_to(:show, global_tag)
end
it "allow to show personal tag" do
is_expected.to be_able_to(:show, personal_tag)
end
it "allow to show another user's personal tag" do
is_expected.to be_able_to(:show, another_user_tag)
end
end
context "manage" do
it "allow to manage user's personal tag" do
is_expected.to be_able_to(:manage, personal_tag)
end
it "don't allow to manage another user's personal tag" do
is_expected.not_to be_able_to(:manage, another_user_tag)
end
end
context "create" do
let(:new_tag) { Tag.new(global: false) }
let(:new_global_tag) { Tag.new }
it "allow to create non-global tag" do
is_expected.to be_able_to(:create, new_tag)
end
it "don't allow to create global tag" do
is_expected.not_to be_able_to(:create, new_global_tag)
end
end
end
end

View File

@@ -0,0 +1,72 @@
require "rails_helper"
require "cancan/matchers"
RSpec.describe Ability do
let!(:user) { create(:user) }
subject { Ability.new(user) }
context "for treatments" do
let!(:global_treatment) { create(:treatment) }
let!(:personal_treatment) { create(:user_treatment, user: user).treatment }
let!(:another_user_treatment) { create(:user_treatment).treatment }
let!(:popular_treatment) { create(:treatment, :personal) }
before { create_list(:user_treatment, Flaredown.config.trackables_min_popularity, treatment: popular_treatment) }
context "index" do
it "allow to index personal treatments" do
is_expected.to be_able_to(:index, personal_treatment)
end
it "allow to index global treatments" do
is_expected.to be_able_to(:index, global_treatment)
end
it "don't allow to index another user's personal treatment" do
is_expected.not_to be_able_to(:index, another_user_treatment)
end
end
context "show" do
it "allow to show global treatments" do
is_expected.to be_able_to(:show, global_treatment)
end
it "allow to show personal treatments" do
is_expected.to be_able_to(:show, personal_treatment)
end
it "allow to show popular treatments" do
is_expected.to be_able_to(:show, popular_treatment)
end
it "allow to show another user's personal treatments" do
is_expected.to be_able_to(:show, another_user_treatment)
end
end
context "manage" do
it "allow to manage user's personal treatments" do
is_expected.to be_able_to(:manage, personal_treatment)
end
it "don't allow to manage another user's personal treatments" do
is_expected.not_to be_able_to(:manage, another_user_treatment)
end
end
context "create" do
let(:new_treatment) { Treatment.new(global: false) }
let(:new_global_treatment) { Treatment.new }
it "allow to create non-global treatments" do
is_expected.to be_able_to(:create, new_treatment)
end
it "don't allow to create global treatments" do
is_expected.not_to be_able_to(:create, new_global_treatment)
end
end
context "popular treatmnets" do
before { create_list(:user_treatment, Flaredown.config.trackables_min_popularity, treatment: popular_treatment) }
let(:popular_treatment_ids) { Ability.new(user).send(:popular_trackable_ids, "Treatment") }
it { expect(popular_treatment_ids).to eq([popular_treatment.id]) }
end
end
end