Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
ddb7399a
Commit
ddb7399a
authored
Nov 25, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for exporting commits as diff or patch
parent
3b7c2adf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
spec/controllers/commit_controller_spec.rb
spec/controllers/commit_controller_spec.rb
+74
-0
No files found.
spec/controllers/commit_controller_spec.rb
0 → 100644
View file @
ddb7399a
require
'spec_helper'
describe
CommitController
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:commit
)
{
project
.
last_commit_for
(
"master"
)
}
before
do
sign_in
(
user
)
project
.
add_access
(
user
,
:read
,
:admin
)
end
describe
"#show"
do
shared_examples
"export as"
do
|
format
|
it
"should generally work"
do
get
:show
,
project_id:
project
.
code
,
id:
commit
.
id
,
format:
format
expect
(
response
).
to
be_success
end
it
"should generate it"
do
Commit
.
any_instance
.
should_receive
(
:"to_
#{
format
}
"
)
get
:show
,
project_id:
project
.
code
,
id:
commit
.
id
,
format:
format
end
it
"should render it"
do
get
:show
,
project_id:
project
.
code
,
id:
commit
.
id
,
format:
format
expect
(
response
.
body
).
to
eq
(
commit
.
send
(
:"to_
#{
format
}
"
))
end
it
"should not escape Html"
do
Commit
.
any_instance
.
stub
(
:"to_
#{
format
}
"
).
and_return
(
'HTML entities &<>" '
)
get
:show
,
project_id:
project
.
code
,
id:
commit
.
id
,
format:
format
expect
(
response
.
body
).
to_not
include
(
'&'
)
expect
(
response
.
body
).
to_not
include
(
'>'
)
expect
(
response
.
body
).
to_not
include
(
'<'
)
expect
(
response
.
body
).
to_not
include
(
'"'
)
end
end
describe
"as diff"
do
include_examples
"export as"
,
:diff
let
(
:format
)
{
:diff
}
it
"should really only be a git diff"
do
get
:show
,
project_id:
project
.
code
,
id:
commit
.
id
,
format:
format
expect
(
response
.
body
).
to
start_with
(
"diff --git"
)
end
end
describe
"as patch"
do
include_examples
"export as"
,
:patch
let
(
:format
)
{
:patch
}
it
"should really be a git email patch"
do
get
:show
,
project_id:
project
.
code
,
id:
commit
.
id
,
format:
format
expect
(
response
.
body
).
to
start_with
(
"From
#{
commit
.
id
}
"
)
end
it
"should contain a git diff"
do
get
:show
,
project_id:
project
.
code
,
id:
commit
.
id
,
format:
format
expect
(
response
.
body
).
to
match
(
/^diff --git/
)
end
end
end
end
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