Browse Source

Fabricator specs (#23925)

closed-social-glitch-2
Matt Jankowski 1 year ago
committed by GitHub
parent
commit
cd99fa8ceb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 27 additions and 183 deletions
  1. +0
    -7
      spec/fabricators/account_alias_fabricator.rb
  2. +0
    -5
      spec/fabricators/account_deletion_request_fabricator.rb
  3. +1
    -0
      spec/fabricators/account_migration_fabricator.rb
  4. +2
    -1
      spec/fabricators/account_moderation_note_fabricator.rb
  5. +3
    -2
      spec/fabricators/account_pin_fabricator.rb
  6. +4
    -4
      spec/fabricators/account_stat_fabricator.rb
  7. +0
    -5
      spec/fabricators/account_tag_stat_fabricator.rb
  8. +0
    -5
      spec/fabricators/account_warning_preset_fabricator.rb
  9. +1
    -1
      spec/fabricators/admin_action_log_fabricator.rb
  10. +0
    -6
      spec/fabricators/announcement_mute_fabricator.rb
  11. +0
    -7
      spec/fabricators/announcement_reaction_fabricator.rb
  12. +0
    -8
      spec/fabricators/conversation_account_fabricator.rb
  13. +0
    -4
      spec/fabricators/conversation_mute_fabricator.rb
  14. +0
    -5
      spec/fabricators/custom_emoji_category_fabricator.rb
  15. +0
    -10
      spec/fabricators/encrypted_message_fabricator.rb
  16. +0
    -8
      spec/fabricators/featured_tag_fabricator.rb
  17. +0
    -5
      spec/fabricators/follow_recommendation_suppression_fabricator.rb
  18. +1
    -1
      spec/fabricators/identity_fabricator.rb
  19. +0
    -4
      spec/fabricators/import_fabricator.rb
  20. +0
    -8
      spec/fabricators/ip_block_fabricator.rb
  21. +0
    -7
      spec/fabricators/list_account_fabricator.rb
  22. +0
    -13
      spec/fabricators/one_time_key_fabricator.rb
  23. +1
    -0
      spec/fabricators/setting_fabricator.rb
  24. +1
    -0
      spec/fabricators/site_upload_fabricator.rb
  25. +0
    -9
      spec/fabricators/status_edit_fabricator.rb
  26. +0
    -8
      spec/fabricators/status_stat_fabricator.rb
  27. +1
    -1
      spec/fabricators/unavailable_domain_fabricator.rb
  28. +0
    -6
      spec/fabricators/user_invite_request_fabricator.rb
  29. +0
    -4
      spec/fabricators/web_setting_fabricator.rb
  30. +12
    -0
      spec/fabricators_spec.rb
  31. +0
    -6
      spec/models/account_spec.rb
  32. +0
    -5
      spec/models/block_spec.rb
  33. +0
    -5
      spec/models/domain_block_spec.rb
  34. +0
    -7
      spec/models/email_domain_block_spec.rb
  35. +0
    -5
      spec/models/follow_spec.rb
  36. +0
    -5
      spec/models/mention_spec.rb
  37. +0
    -6
      spec/models/report_spec.rb

+ 0
- 7
spec/fabricators/account_alias_fabricator.rb View File

@ -1,7 +0,0 @@
# frozen_string_literal: true
Fabricator(:account_alias) do
account
acct 'test@example.com'
uri 'https://example.com/users/test'
end

+ 0
- 5
spec/fabricators/account_deletion_request_fabricator.rb View File

@ -1,5 +0,0 @@
# frozen_string_literal: true
Fabricator(:account_deletion_request) do
account
end

+ 1
- 0
spec/fabricators/account_migration_fabricator.rb View File

@ -5,4 +5,5 @@ Fabricator(:account_migration) do
target_account { |attrs| Fabricate(:account, also_known_as: [ActivityPub::TagManager.instance.uri_for(attrs[:account])]) }
acct { |attrs| attrs[:target_account].acct }
followers_count 1234
created_at { 60.days.ago }
end

+ 2
- 1
spec/fabricators/account_moderation_note_fabricator.rb View File

@ -2,5 +2,6 @@
Fabricator(:account_moderation_note) do
content 'MyText'
account nil
account
target_account { Fabricate(:account) }
end

+ 3
- 2
spec/fabricators/account_pin_fabricator.rb View File

@ -1,6 +1,7 @@
# frozen_string_literal: true
Fabricator(:account_pin) do
account nil
target_account nil
account
target_account(fabricator: :account)
before_create { |account_pin, _| account_pin.account.follow!(account_pin.target_account) }
end

+ 4
- 4
spec/fabricators/account_stat_fabricator.rb View File

@ -1,8 +1,8 @@
# frozen_string_literal: true
Fabricator(:account_stat) do
account nil
statuses_count ''
following_count ''
followers_count ''
account
statuses_count '123'
following_count '456'
followers_count '789'
end

+ 0
- 5
spec/fabricators/account_tag_stat_fabricator.rb View File

@ -1,5 +0,0 @@
# frozen_string_literal: true
Fabricator(:account_tag_stat) do
accounts_count ''
end

+ 0
- 5
spec/fabricators/account_warning_preset_fabricator.rb View File

@ -1,5 +0,0 @@
# frozen_string_literal: true
Fabricator(:account_warning_preset) do
text 'MyText'
end

+ 1
- 1
spec/fabricators/admin_action_log_fabricator.rb View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
Fabricator('Admin::ActionLog') do
account nil
account
action 'MyString'
target nil
end

+ 0
- 6
spec/fabricators/announcement_mute_fabricator.rb View File

@ -1,6 +0,0 @@
# frozen_string_literal: true
Fabricator(:announcement_mute) do
account
announcement
end

+ 0
- 7
spec/fabricators/announcement_reaction_fabricator.rb View File

@ -1,7 +0,0 @@
# frozen_string_literal: true
Fabricator(:announcement_reaction) do
account
announcement
name '🌿'
end

+ 0
- 8
spec/fabricators/conversation_account_fabricator.rb View File

@ -1,8 +0,0 @@
# frozen_string_literal: true
Fabricator(:conversation_account) do
account nil
conversation nil
participant_account_ids ''
last_status nil
end

+ 0
- 4
spec/fabricators/conversation_mute_fabricator.rb View File

@ -1,4 +0,0 @@
# frozen_string_literal: true
Fabricator(:conversation_mute) do
end

+ 0
- 5
spec/fabricators/custom_emoji_category_fabricator.rb View File

@ -1,5 +0,0 @@
# frozen_string_literal: true
Fabricator(:custom_emoji_category) do
name 'MyString'
end

+ 0
- 10
spec/fabricators/encrypted_message_fabricator.rb View File

@ -1,10 +0,0 @@
# frozen_string_literal: true
Fabricator(:encrypted_message) do
device
from_account
from_device_id { Faker::Number.number(digits: 5) }
type 0
body ''
message_franking ''
end

+ 0
- 8
spec/fabricators/featured_tag_fabricator.rb View File

@ -1,8 +0,0 @@
# frozen_string_literal: true
Fabricator(:featured_tag) do
account
tag
statuses_count 1_337
last_status_at Time.now.utc
end

+ 0
- 5
spec/fabricators/follow_recommendation_suppression_fabricator.rb View File

@ -1,5 +0,0 @@
# frozen_string_literal: true
Fabricator(:follow_recommendation_suppression) do
account
end

+ 1
- 1
spec/fabricators/identity_fabricator.rb View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
Fabricator(:identity) do
user nil
user
provider 'MyString'
uid 'MyString'
end

+ 0
- 4
spec/fabricators/import_fabricator.rb View File

@ -1,4 +0,0 @@
# frozen_string_literal: true
Fabricator(:import) do
end

+ 0
- 8
spec/fabricators/ip_block_fabricator.rb View File

@ -1,8 +0,0 @@
# frozen_string_literal: true
Fabricator(:ip_block) do
ip ''
severity ''
expires_at '2020-10-08 22:20:37'
comment 'MyText'
end

+ 0
- 7
spec/fabricators/list_account_fabricator.rb View File

@ -1,7 +0,0 @@
# frozen_string_literal: true
Fabricator(:list_account) do
list nil
account nil
follow nil
end

+ 0
- 13
spec/fabricators/one_time_key_fabricator.rb View File

@ -1,13 +0,0 @@
# frozen_string_literal: true
Fabricator(:one_time_key) do
device
key_id { Faker::Alphanumeric.alphanumeric(number: 10) }
key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) }
signature do |attrs|
signing_key = Ed25519::SigningKey.generate
attrs[:device].update(fingerprint_key: Base64.strict_encode64(signing_key.verify_key.to_bytes))
Base64.strict_encode64(signing_key.sign(attrs[:key]))
end
end

+ 1
- 0
spec/fabricators/setting_fabricator.rb View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
Fabricator(:setting) do
var 'var'
end

+ 1
- 0
spec/fabricators/site_upload_fabricator.rb View File

@ -2,4 +2,5 @@
Fabricator(:site_upload) do
file { Rails.root.join('spec', 'fabricators', 'assets', 'utah_teapot.png').open }
var 'thumbnail'
end

+ 0
- 9
spec/fabricators/status_edit_fabricator.rb View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
Fabricator(:status_edit) do
status nil
account nil
text 'MyText'
spoiler_text 'MyText'
media_attachments_changed false
end

+ 0
- 8
spec/fabricators/status_stat_fabricator.rb View File

@ -1,8 +0,0 @@
# frozen_string_literal: true
Fabricator(:status_stat) do
status_id nil
replies_count ''
reblogs_count ''
favourites_count ''
end

+ 1
- 1
spec/fabricators/unavailable_domain_fabricator.rb View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
Fabricator(:unavailable_domain) do
domain { Faker::Internet.domain }
domain { Faker::Internet.domain_name }
end

+ 0
- 6
spec/fabricators/user_invite_request_fabricator.rb View File

@ -1,6 +0,0 @@
# frozen_string_literal: true
Fabricator(:user_invite_request) do
user
text { Faker::Lorem.sentence }
end

+ 0
- 4
spec/fabricators/web_setting_fabricator.rb View File

@ -1,4 +0,0 @@
# frozen_string_literal: true
Fabricator(:web_setting, from: Web::Setting) do
end

+ 12
- 0
spec/fabricators_spec.rb View File

@ -0,0 +1,12 @@
require 'rails_helper'
Fabrication.manager.load_definitions if Fabrication.manager.empty?
Fabrication.manager.schematics.map(&:first).each do |factory_name|
describe "The #{factory_name} factory" do
it 'is valid' do
factory = Fabricate(factory_name)
expect(factory).to be_valid
end
end
end

+ 0
- 6
spec/models/account_spec.rb View File

@ -704,12 +704,6 @@ RSpec.describe Account, type: :model do
end
describe 'validations' do
it 'has a valid fabricator' do
account = Fabricate.build(:account)
account.valid?
expect(account).to be_valid
end
it 'is invalid without a username' do
account = Fabricate.build(:account, username: nil)
account.valid?

+ 0
- 5
spec/models/block_spec.rb View File

@ -4,11 +4,6 @@ require 'rails_helper'
RSpec.describe Block, type: :model do
describe 'validations' do
it 'has a valid fabricator' do
block = Fabricate.build(:block)
expect(block).to be_valid
end
it 'is invalid without an account' do
block = Fabricate.build(:block, account: nil)
block.valid?

+ 0
- 5
spec/models/domain_block_spec.rb View File

@ -4,11 +4,6 @@ require 'rails_helper'
RSpec.describe DomainBlock, type: :model do
describe 'validations' do
it 'has a valid fabricator' do
domain_block = Fabricate.build(:domain_block)
expect(domain_block).to be_valid
end
it 'is invalid without a domain' do
domain_block = Fabricate.build(:domain_block, domain: nil)
domain_block.valid?

+ 0
- 7
spec/models/email_domain_block_spec.rb View File

@ -3,13 +3,6 @@
require 'rails_helper'
RSpec.describe EmailDomainBlock, type: :model do
describe 'validations' do
it 'has a valid fabricator' do
email_domain_block = Fabricate.build(:email_domain_block)
expect(email_domain_block).to be_valid
end
end
describe 'block?' do
let(:input) { nil }

+ 0
- 5
spec/models/follow_spec.rb View File

@ -9,11 +9,6 @@ RSpec.describe Follow, type: :model do
describe 'validations' do
subject { Follow.new(account: alice, target_account: bob, rate_limit: true) }
it 'has a valid fabricator' do
follow = Fabricate.build(:follow)
expect(follow).to be_valid
end
it 'is invalid without an account' do
follow = Fabricate.build(:follow, account: nil)
follow.valid?

+ 0
- 5
spec/models/mention_spec.rb View File

@ -4,11 +4,6 @@ require 'rails_helper'
RSpec.describe Mention, type: :model do
describe 'validations' do
it 'has a valid fabricator' do
mention = Fabricate.build(:mention)
expect(mention).to be_valid
end
it 'is invalid without an account' do
mention = Fabricate.build(:mention, account: nil)
mention.valid?

+ 0
- 6
spec/models/report_spec.rb View File

@ -121,12 +121,6 @@ describe Report do
end
describe 'validations' do
it 'has a valid fabricator' do
report = Fabricate(:report)
report.valid?
expect(report).to be_valid
end
it 'is invalid if comment is longer than 1000 characters' do
report = Fabricate.build(:report, comment: Faker::Lorem.characters(number: 1001))
report.valid?

Loading…
Cancel
Save