Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
annotate
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
annotate
Commits
3be824bb
Unverified
Commit
3be824bb
authored
Feb 05, 2020
by
Shu Fujita
Committed by
GitHub
Feb 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor RSpec for AnnotateModels - with Globalize gem (#749)
Refactor test cases for AnnotateModels.get_schema_info with Globalize gem
parent
5ee617e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
33 deletions
+43
-33
annotate_models_spec.rb
spec/lib/annotate/annotate_models_spec.rb
+43
-33
No files found.
spec/lib/annotate/annotate_models_spec.rb
View file @
3be824bb
...
...
@@ -761,6 +761,49 @@ describe AnnotateModels do
end
end
end
context
'with Globalize gem'
do
let
:translation_klass
do
double
(
'Post::Translation'
,
to_s:
'Post::Translation'
,
columns:
[
mock_column
(
:id
,
:integer
,
limit:
8
),
mock_column
(
:post_id
,
:integer
,
limit:
8
),
mock_column
(
:locale
,
:string
,
limit:
50
),
mock_column
(
:title
,
:string
,
limit:
50
),
])
end
let
:klass
do
mock_class
(
:posts
,
primary_key
,
columns
,
indexes
,
foreign_keys
).
tap
do
|
mock_klass
|
allow
(
mock_klass
).
to
receive
(
:translation_class
).
and_return
(
translation_klass
)
end
end
let
:columns
do
[
mock_column
(
:id
,
:integer
,
limit:
8
),
mock_column
(
:author_name
,
:string
,
limit:
50
),
]
end
let
:expected_result
do
<<~
EOS
# Schema Info
#
# Table name: posts
#
# id :integer not null, primary key
# author_name :string(50) not null
# title :string(50) not null
#
EOS
end
it
'returns schema info'
do
is_expected
.
to
eq
expected_result
end
end
end
context
'when the primary key is an array (using composite_primary_keys)'
do
...
...
@@ -1140,39 +1183,6 @@ describe AnnotateModels do
end
end
it
'should work with the Globalize gem'
do
klass
=
mock_class
(
:posts
,
:id
,
[
mock_column
(
:id
,
:integer
,
limit:
8
),
mock_column
(
:author_name
,
:string
,
limit:
50
),
])
options
=
{
to_s:
'Post::Translation'
,
columns:
[
mock_column
(
:id
,
:integer
,
limit:
8
),
mock_column
(
:post_id
,
:integer
,
limit:
8
),
mock_column
(
:locale
,
:string
,
limit:
50
),
mock_column
(
:title
,
:string
,
limit:
50
),
]
}
translation_klass
=
double
(
'Post::Translation'
,
options
)
allow
(
klass
).
to
receive
(
:translation_class
).
and_return
(
translation_klass
)
expected_schema_info
=
<<~
EOS
# Schema Info
#
# Table name: posts
#
# id :integer not null, primary key
# author_name :string(50) not null
# title :string(50) not null
#
EOS
expect
(
AnnotateModels
.
get_schema_info
(
klass
,
'Schema Info'
)).
to
eql
(
expected_schema_info
)
end
describe
'.set_defaults'
do
subject
do
Annotate
::
Helpers
.
true?
(
ENV
[
'show_complete_foreign_keys'
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment