Commit b73d4419 authored by Alex Denisov's avatar Alex Denisov

json_spec added. Create project via REST API fixed

parent 6b3ce96a
...@@ -117,6 +117,7 @@ group :test do ...@@ -117,6 +117,7 @@ group :test do
gem 'email_spec' gem 'email_spec'
gem 'resque_spec' gem 'resque_spec'
gem "webmock" gem "webmock"
gem 'json_spec'
end end
group :production do group :production do
......
...@@ -207,6 +207,9 @@ GEM ...@@ -207,6 +207,9 @@ GEM
jquery-rails jquery-rails
railties (>= 3.1.0) railties (>= 3.1.0)
json (1.7.5) json (1.7.5)
json_spec (1.0.3)
multi_json (~> 1.0)
rspec (~> 2.0)
kaminari (0.14.0) kaminari (0.14.0)
actionpack (>= 3.0.0) actionpack (>= 3.0.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
...@@ -406,6 +409,7 @@ DEPENDENCIES ...@@ -406,6 +409,7 @@ DEPENDENCIES
httparty httparty
jquery-rails (= 2.0.2) jquery-rails (= 2.0.2)
jquery-ui-rails (= 0.5.0) jquery-ui-rails (= 0.5.0)
json_spec
kaminari kaminari
launchy launchy
letter_opener letter_opener
......
...@@ -11,6 +11,9 @@ module Factory ...@@ -11,6 +11,9 @@ module Factory
def self.new(type, *args) def self.new(type, *args)
FactoryGirl.build(type, *args) FactoryGirl.build(type, *args)
end end
def self.attributes(type, *args)
FactoryGirl.attributes_for(type, *args)
end
end end
FactoryGirl.define do FactoryGirl.define do
......
...@@ -39,55 +39,19 @@ describe Gitlab::API do ...@@ -39,55 +39,19 @@ describe Gitlab::API do
}.should change{Project.count}.by(1) }.should change{Project.count}.by(1)
end end
it "should create new project" do it "should create new project" do
expect { attributes = Factory.attributes(:project,
name = "foo" name: "foo",
path = "bar" path: "bar",
code = "bazz" code: "bazz",
description = "fuu project" description: "foo project",
default_branch = "default_branch" default_branch: "default_branch",
issues_enabled = false issues_enabled: false,
wall_enabled = false wall_enabled: false,
merge_requests_enabled = false merge_requests_enabled: false,
wiki_enabled = false wiki_enabled: false)
post api("/projects", user), { post api("/projects", user), attributes
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 response.status.should == 201
json_response["name"].should == name response.body.should be_json_eql(attributes.to_json).excluding("owner", "private")
json_response["path"].should == path
json_response["code"].should == code
}.should change{Project.count}.by(1)
end end
it "should not create project without name" do it "should not create project without name" do
expect { expect {
......
...@@ -28,6 +28,7 @@ RSpec.configure do |config| ...@@ -28,6 +28,7 @@ RSpec.configure do |config|
config.include LoginHelpers, type: :request config.include LoginHelpers, type: :request
config.include GitoliteStub config.include GitoliteStub
config.include FactoryGirl::Syntax::Methods 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 # 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 # 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