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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
d4543eb5
Commit
d4543eb5
authored
Mar 25, 2013
by
Andrew8xx8
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests fixed
parent
611ac727
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
14 deletions
+49
-14
app/controllers/projects/snippets_controller.rb
app/controllers/projects/snippets_controller.rb
+2
-2
app/models/ability.rb
app/models/ability.rb
+4
-4
lib/api/projects.rb
lib/api/projects.rb
+3
-3
spec/helpers/gitlab_markdown_helper_spec.rb
spec/helpers/gitlab_markdown_helper_spec.rb
+37
-2
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-1
spec/requests/api/notes_spec.rb
spec/requests/api/notes_spec.rb
+1
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+1
-1
No files found.
app/controllers/projects/snippets_controller.rb
View file @
d4543eb5
...
...
@@ -23,11 +23,11 @@ class Projects::SnippetsController < Projects::ApplicationController
end
def
new
@snippet
=
@project
.
snippets
.
new
@snippet
=
@project
.
snippets
.
build
end
def
create
@snippet
=
@project
.
snippets
.
new
(
params
[
:project_snippet
])
@snippet
=
@project
.
snippets
.
build
(
params
[
:project_snippet
])
@snippet
.
author
=
current_user
@snippet
.
save
...
...
app/models/ability.rb
View file @
d4543eb5
...
...
@@ -55,7 +55,7 @@ class Ability
:read_wiki
,
:read_issue
,
:read_milestone
,
:read_snippet
,
:read_
project_
snippet
,
:read_team_member
,
:read_merge_request
,
:read_note
,
...
...
@@ -68,7 +68,7 @@ class Ability
def
project_report_rules
project_guest_rules
+
[
:download_code
,
:write_snippet
:write_
project_
snippet
]
end
...
...
@@ -84,11 +84,11 @@ class Ability
project_dev_rules
+
[
:push_code_to_protected_branches
,
:modify_issue
,
:modify_snippet
,
:modify_
project_
snippet
,
:modify_merge_request
,
:admin_issue
,
:admin_milestone
,
:admin_snippet
,
:admin_
project_
snippet
,
:admin_team_member
,
:admin_merge_request
,
:admin_note
,
...
...
lib/api/projects.rb
View file @
d4543eb5
...
...
@@ -408,7 +408,7 @@ module Gitlab
# Example Request:
# POST /projects/:id/snippets
post
":id/snippets"
do
authorize!
:write_snippet
,
user_project
authorize!
:write_
project_
snippet
,
user_project
required_attributes!
[
:title
,
:file_name
,
:code
]
attrs
=
attributes_for_keys
[
:title
,
:file_name
]
...
...
@@ -437,7 +437,7 @@ module Gitlab
# PUT /projects/:id/snippets/:snippet_id
put
":id/snippets/:snippet_id"
do
@snippet
=
user_project
.
snippets
.
find
(
params
[
:snippet_id
])
authorize!
:modify_snippet
,
@snippet
authorize!
:modify_
project_
snippet
,
@snippet
attrs
=
attributes_for_keys
[
:title
,
:file_name
]
attrs
[
:expires_at
]
=
params
[
:lifetime
]
if
params
[
:lifetime
].
present?
...
...
@@ -460,7 +460,7 @@ module Gitlab
delete
":id/snippets/:snippet_id"
do
begin
@snippet
=
user_project
.
snippets
.
find
(
params
[
:snippet_id
])
authorize!
:modify_
snippet
,
user_projec
t
authorize!
:modify_
project_snippet
,
@snippe
t
@snippet
.
destroy
rescue
end
...
...
spec/helpers/gitlab_markdown_helper_spec.rb
View file @
d4543eb5
...
...
@@ -10,7 +10,7 @@ describe GitlabMarkdownHelper do
let
(
:commit
)
{
CommitDecorator
.
decorate
(
project
.
repository
.
commit
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
project:
project
)
}
let
(
:snippet
)
{
create
(
:snippet
,
project:
project
)
}
let
(
:snippet
)
{
create
(
:
project_
snippet
,
project:
project
)
}
let
(
:member
)
{
project
.
users_projects
.
where
(
user_id:
user
).
first
}
before
do
...
...
@@ -190,8 +190,43 @@ describe GitlabMarkdownHelper do
describe
"referencing a snippet"
do
let
(
:object
)
{
snippet
}
let
(
:reference
)
{
"$
#{
snippet
.
id
}
"
}
let
(
:actual
)
{
"Reference to
#{
reference
}
"
}
let
(
:expected
)
{
project_snippet_path
(
project
,
object
)
}
it
"should link using a valid id"
do
gfm
(
actual
).
should
match
(
expected
)
end
it
"should link with adjacent text"
do
# Wrap the reference in parenthesis
gfm
(
actual
.
gsub
(
reference
,
"(
#{
reference
}
)"
)).
should
match
(
expected
)
# Append some text to the end of the reference
gfm
(
actual
.
gsub
(
reference
,
"
#{
reference
}
, right?"
)).
should
match
(
expected
)
end
it
"should keep whitespace intact"
do
actual
=
"Referenced
#{
reference
}
already."
expected
=
/Referenced <a.+>[^\s]+<\/a> already/
gfm
(
actual
).
should
match
(
expected
)
end
it
"should not link with an invalid id"
do
# Modify the reference string so it's still parsed, but is invalid
reference
.
gsub!
(
/^(.)(\d+)$/
,
'\1'
+
(
'\2'
*
2
))
gfm
(
actual
).
should
==
actual
end
it
"should include a title attribute"
do
title
=
"Snippet:
#{
object
.
title
}
"
gfm
(
actual
).
should
match
(
/title="
#{
title
}
"/
)
end
it
"should include standard gfm classes"
do
css
=
object
.
class
.
to_s
.
underscore
gfm
(
actual
).
should
match
(
/class="\s?gfm gfm-snippet\s?"/
)
end
include_examples
'referenced object'
end
describe
"referencing multiple objects"
do
...
...
spec/models/project_spec.rb
View file @
d4543eb5
...
...
@@ -34,7 +34,7 @@ describe Project do
it
{
should
have_many
(
:milestones
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:users_projects
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:notes
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:
snippets
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:
project_snippets
).
class_name
(
'ProjectSnippet'
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:deploy_keys
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:hooks
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:wikis
).
dependent
(
:destroy
)
}
...
...
spec/requests/api/notes_spec.rb
View file @
d4543eb5
...
...
@@ -7,7 +7,7 @@ describe Gitlab::API do
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
project:
project
,
author:
user
)
}
let!
(
:snippet
)
{
create
(
:snippet
,
project:
project
,
author:
user
)
}
let!
(
:snippet
)
{
create
(
:
project_
snippet
,
project:
project
,
author:
user
)
}
let!
(
:issue_note
)
{
create
(
:note
,
noteable:
issue
,
project:
project
,
author:
user
)
}
let!
(
:merge_request_note
)
{
create
(
:note
,
noteable:
merge_request
,
project:
project
,
author:
user
)
}
let!
(
:snippet_note
)
{
create
(
:note
,
noteable:
snippet
,
project:
project
,
author:
user
)
}
...
...
spec/requests/api/projects_spec.rb
View file @
d4543eb5
...
...
@@ -9,7 +9,7 @@ describe Gitlab::API do
let
(
:admin
)
{
create
(
:admin
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:hook
)
{
create
(
:project_hook
,
project:
project
,
url:
"http://example.com"
)
}
let!
(
:snippet
)
{
create
(
:snippet
,
author:
user
,
project:
project
,
title:
'example'
)
}
let!
(
:snippet
)
{
create
(
:
project_
snippet
,
author:
user
,
project:
project
,
title:
'example'
)
}
let!
(
:users_project
)
{
create
(
:users_project
,
user:
user
,
project:
project
,
project_access:
UsersProject
::
MASTER
)
}
let!
(
:users_project2
)
{
create
(
:users_project
,
user:
user3
,
project:
project
,
project_access:
UsersProject
::
DEVELOPER
)
}
let
(
:key
)
{
create
(
:key
,
project:
project
)
}
...
...
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