Skip to content

Commit

Permalink
remove check for missing attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
NARKOZ committed Apr 21, 2015
1 parent 8896e2b commit 9acb83d
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 38 deletions.
12 changes: 0 additions & 12 deletions lib/gitlab/client/merge_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ def merge_request(project, id)
# @option options [Integer] :target_project_id (optional) The target project ID.
# @return [Gitlab::ObjectifiedHash] Information about created merge request.
def create_merge_request(project, title, options={})
check_attributes!(options, [:source_branch, :target_branch])

body = {:title => title}.merge(options)
post("/projects/#{project}/merge_requests", :body => body)
end
Expand Down Expand Up @@ -125,15 +123,5 @@ def merge_request_comments(project, id, options={})
def merge_request_changes(project, id)
get("/projects/#{project}/merge_request/#{id}/changes")
end

private

def check_attributes!(options, attrs)
attrs.each do |attr|
unless options.has_key?(attr) || options.has_key?(attr.to_s)
raise Gitlab::Error::MissingAttributes.new("Missing '#{attr}' parameter")
end
end
end
end
end
11 changes: 0 additions & 11 deletions lib/gitlab/client/snippets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def snippet(project, id)
# @option options [String] :lifetime (optional) The expiration date of a snippet.
# @return [Gitlab::ObjectifiedHash] Information about created snippet.
def create_snippet(project, options={})
check_attributes!(options, [:title, :file_name, :code])
post("/projects/#{project}/snippets", :body => options)
end

Expand Down Expand Up @@ -73,15 +72,5 @@ def edit_snippet(project, id, options={})
def delete_snippet(project, id)
delete("/projects/#{project}/snippets/#{id}")
end

private

def check_attributes!(options, attrs)
attrs.each do |attr|
unless options.has_key?(attr) || options.has_key?(attr.to_s)
raise Gitlab::Error::MissingAttributes.new("Missing '#{attr}' parameter")
end
end
end
end
end
3 changes: 0 additions & 3 deletions lib/gitlab/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ module Error
# Custom error class for rescuing from all Gitlab errors.
class Error < StandardError; end

# Raise when attributes are missing.
class MissingAttributes < Error; end

# Raised when API endpoint credentials not configured.
class MissingCredentials < Error; end

Expand Down
12 changes: 0 additions & 12 deletions spec/gitlab/client/merge_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@
stub_post("/projects/3/merge_requests", "merge_request")
end

it "should fail if it doesn't have a source_branch" do
expect {
Gitlab.create_merge_request(3, 'New merge request', :target_branch => 'master')
}.to raise_error Gitlab::Error::MissingAttributes
end

it "should fail if it doesn't have a target_branch" do
expect {
Gitlab.create_merge_request(3, 'New merge request', :source_branch => 'dev')
}.to raise_error Gitlab::Error::MissingAttributes
end

it "should return information about a merge request" do
@merge_request = Gitlab.create_merge_request(3, 'New feature',
:source_branch => 'api',
Expand Down

0 comments on commit 9acb83d

Please sign in to comment.