Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring: Migrate ticket_article_store_empty to RSpec
- Loading branch information
1 parent
63214c9
commit 107fd5e
Showing
12 changed files
with
410 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
FactoryBot.define do | |||
factory :activity_stream do | |||
transient do | |||
o { Ticket.first } | |||
end | |||
|
|||
association :type, factory: :type_lookup | |||
activity_stream_object_id { ObjectLookup.by_name(o.class.name) } | |||
o_id { o.id } | |||
created_by_id { 1 } | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,8 +1,15 @@ | |||
FactoryBot.define do | FactoryBot.define do | ||
factory :history do | factory :history do | ||
transient do | |||
o { Ticket.first } | |||
end | |||
|
|||
association :history_type, factory: :'history/type' | association :history_type, factory: :'history/type' | ||
association :history_object, factory: :'history/object' | o_id { o.id } | ||
o_id { history_object.name.constantize.pluck(:id).sample } | |||
created_by_id { 1 } | created_by_id { 1 } | ||
|
|||
history_object_id do | |||
History::Object.lookup(name: o.class.name)&.id || create(:'history/object', name: o.class.name).id | |||
end | |||
end | end | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
FactoryBot.define do | |||
factory :'karma/activity_log', aliases: %i[karma_activity_log] do | |||
transient do | |||
o { Ticket.first } | |||
end | |||
|
|||
o_id { o.id } | |||
object_lookup_id { ObjectLookup.by_name(o.class.name) } | |||
user_id { 1 } | |||
activity_id { Karma::Activity.pluck(:id).sample } | |||
score { 100 } | |||
score_total { 100 } | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,7 +1,14 @@ | |||
FactoryBot.define do | FactoryBot.define do | ||
factory :link do | factory :link do | ||
link_type_id { Link::Type.find_by(name: 'normal').id } | transient do | ||
link_object_source_id { Link::Object.find_by(name: 'Ticket').id } | from { Ticket.first } | ||
link_object_target_id { Link::Object.find_by(name: 'Ticket').id } | to { Ticket.last } | ||
end | |||
|
|||
link_type_id { Link::Type.find_by(name: 'normal').id } | |||
link_object_source_id { Link::Object.find_by(name: 'Ticket').id } | |||
link_object_target_id { Link::Object.find_by(name: 'Ticket').id } | |||
link_object_source_value { from.id } | |||
link_object_target_value { to.id } | |||
end | end | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,13 +1,17 @@ | |||
FactoryBot.define do | FactoryBot.define do | ||
factory :online_notification do | factory :online_notification do | ||
object_lookup_id { ObjectLookup.by_name('Ticket') } | transient do | ||
o_id 1 | o { Ticket.first } | ||
type_lookup_id { TypeLookup.by_name('updated') } | end | ||
seen false |
|
||
user_id 1 | object_lookup_id { ObjectLookup.by_name(o.class.name) } | ||
created_by_id 1 | o_id { o.id } | ||
updated_by_id 1 | type_lookup_id { TypeLookup.by_name('updated') } | ||
created_at Time.zone.now | seen { false } | ||
updated_at Time.zone.now | user_id { 1 } | ||
created_by_id { 1 } | |||
updated_by_id { 1 } | |||
created_at { Time.zone.now } | |||
updated_at { Time.zone.now } | |||
end | end | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,7 +1,15 @@ | |||
FactoryBot.define do | FactoryBot.define do | ||
factory :tag do | factory :tag do | ||
tag_object_id { Tag::Object.lookup_by_name_and_create('Ticket').id } | transient do | ||
tag_item_id { Tag::Item.lookup_by_name_and_create('blub').id } | o { Ticket.first } | ||
created_by_id 1 | end | ||
|
|||
tag_item_id { Tag::Item.lookup_by_name_and_create('blub').id } | |||
o_id { o.id } | |||
created_by_id { 1 } | |||
|
|||
tag_object_id do | |||
Tag::Object.lookup(name: o.class.name)&.id || create(:'tag/object', name: o.class.name).id | |||
end | |||
end | end | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
FactoryBot.define do | |||
factory :'tag/object', aliases: %i[tag_object] do | |||
name { (ApplicationModel.descendants.select(&:any?).map(&:name) - Tag::Object.pluck(:name)).sample } | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
FactoryBot.define do | |||
factory :type_lookup do | |||
name do | |||
# The following line ensures that the name generated by Faker | |||
# does not conflict with any existing names in the DB. | |||
# There's a special syntax for this | |||
# (Faker::Verb.unique.exclude(:past_participle, [], Ticket::StateType.pluck(:name)), | |||
# but it's not available yet in the current release of Faker (1.9.1). | |||
Faker::Verb.unique | |||
.instance_variable_get(:@previous_results) | |||
.dig([:base, []]) | |||
.merge(TypeLookup.pluck(:name)) | |||
|
|||
Faker::Verb.unique.base | |||
end | |||
end | |||
end |
Oops, something went wrong.