From bbe0062bfd6078f7ebd1fff63f19cdc073b88248 Mon Sep 17 00:00:00 2001 From: Urban Rotnik Date: Mon, 10 Jun 2019 12:19:10 +0200 Subject: [PATCH] Small fixes for factories --- app/models/result.rb | 2 +- spec/factories/repository_table_states.rb | 1 + spec/factories/tables.rb | 2 +- spec/factories/view_states.rb | 4 +++- spec/models/view_state_spec.rb | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/models/result.rb b/app/models/result.rb index 25f6e4ed5..d6c66cf72 100644 --- a/app/models/result.rb +++ b/app/models/result.rb @@ -9,7 +9,7 @@ class Result < ApplicationRecord validates :user, :my_module, presence: true validates :name, length: { maximum: Constants::NAME_MAX_LENGTH } - belongs_to :user, inverse_of: :results, optional: true + belongs_to :user, inverse_of: :results belongs_to :last_modified_by, foreign_key: 'last_modified_by_id', class_name: 'User', optional: true belongs_to :archived_by, foreign_key: 'archived_by_id', class_name: 'User', optional: true belongs_to :restored_by, foreign_key: 'restored_by_id', class_name: 'User', optional: true diff --git a/spec/factories/repository_table_states.rb b/spec/factories/repository_table_states.rb index a22568f15..fc65862c9 100644 --- a/spec/factories/repository_table_states.rb +++ b/spec/factories/repository_table_states.rb @@ -4,5 +4,6 @@ FactoryBot.define do factory :repository_table_state do user repository + state { {} } end end diff --git a/spec/factories/tables.rb b/spec/factories/tables.rb index 3abeacf1f..f43110090 100644 --- a/spec/factories/tables.rb +++ b/spec/factories/tables.rb @@ -3,6 +3,6 @@ FactoryBot.define do factory :table do name { Faker::Name.unique.name } - contents { Faker::Lorem.characters } + contents { { some_data: 'needs to be here' } } end end diff --git a/spec/factories/view_states.rb b/spec/factories/view_states.rb index d898bef59..46827da52 100644 --- a/spec/factories/view_states.rb +++ b/spec/factories/view_states.rb @@ -4,6 +4,8 @@ FactoryBot.define do factory :view_state do state {} user - viewable { create :team } + trait :team do + viewable { create :team } + end end end diff --git a/spec/models/view_state_spec.rb b/spec/models/view_state_spec.rb index 3ededbfd5..205dba883 100644 --- a/spec/models/view_state_spec.rb +++ b/spec/models/view_state_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe ViewState, type: :model do - let(:view_state) { build :view_state } + let(:view_state) { build :view_state, :team } it 'is valid' do expect(view_state).to be_valid