Skip to content

Commit

Permalink
all models done
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticspoon committed Mar 25, 2024
1 parent 0d0b686 commit 651f6bf
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions spec/models/concerns/deadlinable_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe Deadlinable, type: :model do
RSpec.describe Deadlinable, type: :model, seed_items: false do
let(:dummy_class) do
Class.new do
def self.name
Expand All @@ -20,7 +20,7 @@ def deadline_day?

subject(:dummy) { dummy_class.new }

describe "validations" do
describe "validations", seed_items: false do
it do
is_expected.to validate_numericality_of(:deadline_day)
.only_integer
Expand Down
4 changes: 2 additions & 2 deletions spec/models/partners/authorized_family_member_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
#
require "rails_helper"

RSpec.describe Partners::AuthorizedFamilyMember, type: :model do
RSpec.describe Partners::AuthorizedFamilyMember, type: :model, seed_items: false do
describe 'associations' do
it { should belong_to(:family) }
it { should have_many(:child_item_requests).dependent(:nullify) }
end

describe "#display_name" do
let(:partners_family) { FactoryBot.create(:partners_family) }
let(:partners_family) { create(:partners_family) }
let(:authorized_family_member) { partners_family.create_authorized }

it "should return the family member's first and last name" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/partners/child_item_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
require 'rails_helper'

RSpec.describe Partners::ChildItemRequest, type: :model do
RSpec.describe Partners::ChildItemRequest, type: :model, seed_items: false do
describe 'associations' do
it { should belong_to(:item_request) }
it { should belong_to(:child) }
Expand Down
4 changes: 2 additions & 2 deletions spec/models/partners/child_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
#
require "rails_helper"

RSpec.describe Partners::Child, type: :model do
RSpec.describe Partners::Child, type: :model, seed_items: false do
describe 'associations' do
it { should belong_to(:family) }
it { should have_many(:child_item_requests).dependent(:destroy) }
end

describe "#display_name" do
subject { partners_child }
let(:partners_child) { FactoryBot.create(:partners_child) }
let(:partners_child) { create(:partners_child) }

it "should return a child's first and last name" do
expect(subject.display_name).to eq("#{subject.first_name} #{subject.last_name}")
Expand Down
2 changes: 1 addition & 1 deletion spec/models/partners/family_request_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe Partners::FamilyRequest do
RSpec.describe Partners::FamilyRequest, seed_items: false do
describe "Partners::FamilyRequest.new_with_attrs" do
it "creates a new FamilyRequest with attributes" do
attributes = [{item_id: 1, person_count: 3}]
Expand Down
2 changes: 1 addition & 1 deletion spec/models/partners/family_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

require "rails_helper"

RSpec.describe Partners::Family, type: :model do
RSpec.describe Partners::Family, type: :model, seed_items: false do
describe "associations" do
it { should belong_to(:partner) }
it { should have_many(:children).dependent(:destroy) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/partners/item_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
require "rails_helper"

RSpec.describe Partners::ItemRequest, type: :model do
RSpec.describe Partners::ItemRequest, type: :model, seed_items: false do
describe 'associations' do
it { should belong_to(:request).class_name('::Request').with_foreign_key(:partner_request_id) }
it { should have_many(:child_item_requests).dependent(:destroy) }
Expand Down
12 changes: 6 additions & 6 deletions spec/models/partners/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
#
require "rails_helper"

RSpec.describe Partners::Profile, type: :model do
RSpec.describe Partners::Profile, type: :model, seed_items: false do
describe "associations" do
it { should have_one_attached(:proof_of_partner_status) }
it { should have_one_attached(:proof_of_form_990) }
Expand All @@ -95,7 +95,7 @@
end

describe "request settings validation for profile" do
subject { FactoryBot.build(:partner_profile, enable_child_based_requests: false, enable_individual_requests: false, enable_quantity_based_requests: false) }
subject { build(:partner_profile, enable_child_based_requests: false, enable_individual_requests: false, enable_quantity_based_requests: false) }

context "no settings are set to true" do
it "should not be valid" do
Expand All @@ -117,7 +117,7 @@

describe "social media info validation for profile" do
context "no social media presence and the checkbox isn't checked" do
let(:profile) { FactoryBot.build(:partner_profile, website: "", twitter: "", facebook: "", instagram: "", no_social_media_presence: false) }
let(:profile) { build(:partner_profile, website: "", twitter: "", facebook: "", instagram: "", no_social_media_presence: false) }

it "should not be valid" do
expect(profile.valid?(:edit)).to eq(false)
Expand All @@ -131,15 +131,15 @@
end

context "no social media presence and the checkbox is checked" do
let(:profile) { FactoryBot.build(:partner_profile, website: "", twitter: "", facebook: "", instagram: "", no_social_media_presence: true) }
let(:profile) { build(:partner_profile, website: "", twitter: "", facebook: "", instagram: "", no_social_media_presence: true) }

it "should be valid" do
expect(profile.valid?(:edit)).to eq(true)
end
end

context "has social media presence and the checkbox is unchecked" do
let(:profile) { FactoryBot.build(:partner_profile, no_social_media_presence: false) }
let(:profile) { build(:partner_profile, no_social_media_presence: false) }

it "with just a website it should be valid" do
profile.update(website: "some website URL", twitter: "", facebook: "", instagram: "")
Expand Down Expand Up @@ -170,7 +170,7 @@

describe "client share behaviour" do
context "no served areas" do
let(:profile) { FactoryBot.build(:partner_profile) }
let(:profile) { build(:partner_profile) }
it "has 0 client share" do
expect(profile.client_share_total).to eq(0)
expect(profile.valid?).to eq(true)
Expand Down
2 changes: 1 addition & 1 deletion spec/models/partners/served_area_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
require "rails_helper"

RSpec.describe Partners::ServedArea, type: :model do
RSpec.describe Partners::ServedArea, type: :model, seed_items: false do
it { should belong_to(:partner_profile) }
it { should belong_to(:county) }

Expand Down
4 changes: 3 additions & 1 deletion spec/models/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
end

describe "total_items" do
let(:request) { create(:request, request_items: [{ item_id: Item.active.first.id, quantity: 15 }, { item_id: Item.active.last.id, quantity: 18 }]) }
let(:id_one) { create(:item).id }
let(:id_two) { create(:item).id }
let(:request) { create(:request, request_items: [{ item_id: id_one, quantity: 15 }, { item_id: id_two, quantity: 18 }]) }

it "adds the quantity of all items in the request" do
expect(request.total_items).to eq(33)
Expand Down

0 comments on commit 651f6bf

Please sign in to comment.