BigW Consortium Gitlab

Commit b73d4419 by Alex Denisov

json_spec added. Create project via REST API fixed

parent 6b3ce96a
......@@ -117,6 +117,7 @@ group :test do
gem 'email_spec'
gem 'resque_spec'
gem "webmock"
gem 'json_spec'
end
group :production do
......
......@@ -207,6 +207,9 @@ GEM
jquery-rails
railties (>= 3.1.0)
json (1.7.5)
json_spec (1.0.3)
multi_json (~> 1.0)
rspec (~> 2.0)
kaminari (0.14.0)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
......@@ -406,6 +409,7 @@ DEPENDENCIES
httparty
jquery-rails (= 2.0.2)
jquery-ui-rails (= 0.5.0)
json_spec
kaminari
launchy
letter_opener
......
......@@ -11,6 +11,9 @@ module Factory
def self.new(type, *args)
FactoryGirl.build(type, *args)
end
def self.attributes(type, *args)
FactoryGirl.attributes_for(type, *args)
end
end
FactoryGirl.define do
......
......@@ -39,55 +39,19 @@ describe Gitlab::API do
}.should change{Project.count}.by(1)
end
it "should create new project" do
expect {
name = "foo"
path = "bar"
code = "bazz"
description = "fuu project"
default_branch = "default_branch"
issues_enabled = false
wall_enabled = false
merge_requests_enabled = false
wiki_enabled = false
post api("/projects", user), {
code: code,
path: path,
name: name,
description: description,
default_branch: default_branch,
issues_enabled: issues_enabled,
wall_enabled: wall_enabled,
merge_requests_enabled: merge_requests_enabled,
wiki_enabled: wiki_enabled
}
response.status.should == 201
json_response["name"].should == name
json_response["path"].should == path
json_response["code"].should == code
json_response["description"].should == description
json_response["default_branch"].should == default_branch
json_response["issues_enabled"].should == issues_enabled
json_response["wall_enabled"].should == wall_enabled
json_response["merge_requests_enabled"].should == merge_requests_enabled
json_response["wiki_enabled"].should == wiki_enabled
}.should change{Project.count}.by(1)
end
it "should create new projects within all parameters" do
expect {
name = "foo"
path = "bar"
code = "bazz"
post api("/projects", user), {
code: code,
path: path,
name: name
}
response.status.should == 201
json_response["name"].should == name
json_response["path"].should == path
json_response["code"].should == code
}.should change{Project.count}.by(1)
attributes = Factory.attributes(:project,
name: "foo",
path: "bar",
code: "bazz",
description: "foo project",
default_branch: "default_branch",
issues_enabled: false,
wall_enabled: false,
merge_requests_enabled: false,
wiki_enabled: false)
post api("/projects", user), attributes
response.status.should == 201
response.body.should be_json_eql(attributes.to_json).excluding("owner", "private")
end
it "should not create project without name" do
expect {
......
......@@ -28,6 +28,7 @@ RSpec.configure do |config|
config.include LoginHelpers, type: :request
config.include GitoliteStub
config.include FactoryGirl::Syntax::Methods
config.include JsonSpec::Helpers
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment