Cross Reference: commit_spec.rb
xref
: /
ontohub
/
spec
/
models
/
commit_spec.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
commit_spec.rb revision 81da36894af70bbb8d8e24b004026ad4c5c1bc99
2310
N/A
require
'spec_helper'
2310
N/A
2310
N/A
describe
Commit
do
2310
N/A
context
'associations'
do
2310
N/A
%i
(
ontology_versions
ontologies
)
.
each
do
|
association
|
2310
N/A
it
{
should
have_many
(
association
)
}
2310
N/A
end
2310
N/A
2310
N/A
%i
(
repository
author
committer
pusher
)
.
each
do
|
association
|
2310
N/A
it
{
should
belong_to
(
association
)
}
2310
N/A
end
2310
N/A
end
2310
N/A
2310
N/A
context
'saving a commit'
do
2310
N/A
let
(:
repository
)
{
create
:
repository
}
2310
N/A
let
(:
pusher
)
{
create
:
user
}
2310
N/A
let
(:
file
)
{
'
clif
/
Px.clif
'
}
2310
N/A
2310
N/A
before
do
2310
N/A
stub_hets_for
(
file
)
2310
N/A
end
2310
N/A
3158
N/A
context
'with author, committer and pusher being the same user'
do
2310
N/A
let
!
(:
commit_oid
)
do
3143
N/A
repository.save
_file
(
ontology_file
(
file
)
,
2310
N/A
File.basename
(
file
)
,
'add file'
,
pusher
)
.
commit_oid
2310
N/A
end
2310
N/A
let
(:
commit
)
{
repository.commits.where
(
commit_oid
:
commit_oid
)
.
first
}
2310
N/A
subject
{
commit
}
2310
N/A
2310
N/A
%i
(
author
committer
pusher
)
.
each
do
|
field
|
2310
N/A
it
"saves the #{field}"
do
2310
N/A
expect
(
subject.send
(
field
)
)
.
to
eq
(
pusher
)
2310
N/A
end
2310
N/A
3046
N/A
it
"saves the #{field}_name"
do
3046
N/A
expect
(
subject.send
(
"#{field}_name"
)
)
.
to
eq
(
pusher.name
)
2310
N/A
end
2310
N/A
end
2310
N/A
2310
N/A
%i
(
author
committer
)
.
each
do
|
field
|
2310
N/A
it
"saves the #{field}_email"
do
2310
N/A
expect
(
subject.send
(
"#{field}_email"
)
)
.
to
eq
(
pusher.email
)
2310
N/A
end
2310
N/A
end
2310
N/A
end
2310
N/A
2310
N/A
context
'with different author, committer, pusher'
do
2310
N/A
let
(:
author
)
{
create
:
user
}
2310
N/A
let
(:
committer
)
{
create
:
user
}
2310
N/A
let
(:
author_data
)
do
2310
N/A
{
name
:
author.name
,
email
:
author.email
,
time
:
Time.now
}
3171
N/A
end
3158
N/A
let
(:
committer_data
)
do
2310
N/A
{
name
:
committer.name
,
email
:
committer.email
,
time
:
Time.now
}
2310
N/A
end
2310
N/A
2310
N/A
before
do
2310
N/A
allow_any_instance_of
(
GitRepository
)
.
2310
N/A
to
receive
(:
commit_author
)
.
and_return
(
author_data
)
2310
N/A
allow_any_instance_of
(
GitRepository
)
.
2310
N/A
to
receive
(:
commit_committer
)
.
and_return
(
committer_data
)
2310
N/A
end
2310
N/A
2310
N/A
let
(:
commit_oid
)
do
2310
N/A
repository.save
_file
(
ontology_file
(
file
)
,
2310
N/A
File.basename
(
file
)
,
'add file'
,
pusher
)
.
commit_oid
2310
N/A
end
2310
N/A
let
(:
commit
)
{
repository.commits.where
(
commit_oid
:
commit_oid
)
.
first
}
2310
N/A
subject
{
commit
}
2310
N/A
2310
N/A
it
"saves the author's association"
do
2310
N/A
expect
(
subject.author
)
.
to
eq
(
author
)
2310
N/A
end
3143
N/A
2310
N/A
it
"saves the author's name"
do
3143
N/A
expect
(
subject.author
_name
)
.
to
eq
(
author.name
)
2310
N/A
end
2310
N/A
2310
N/A
it
"saves the author's email"
do
2310
N/A
expect
(
subject.author
_email
)
.
to
eq
(
author.email
)
2310
N/A
end
2310
N/A
2310
N/A
it
"saves the committer's association"
do
2310
N/A
expect
(
subject.committer
)
.
to
eq
(
committer
)
2310
N/A
end
2310
N/A
2310
N/A
it
"saves the committer's name"
do
2310
N/A
expect
(
subject.committer
_name
)
.
to
eq
(
committer.name
)
2310
N/A
end
2310
N/A
2310
N/A
it
"saves the committer's email"
do
2310
N/A
expect
(
subject.committer
_email
)
.
to
eq
(
committer.email
)
2310
N/A
end
2310
N/A
2310
N/A
it
"saves the pusher's association"
do
2310
N/A
expect
(
subject.pusher
)
.
to
eq
(
pusher
)
2310
N/A
end
2310
N/A
2310
N/A
it
"saves the pusher's name"
do
2310
N/A
expect
(
subject.pusher
_name
)
.
to
eq
(
pusher.name
)
2310
N/A
end
2310
N/A
end
2310
N/A
end
2310
N/A
end
2310
N/A