summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Denisov <1101.debian@gmail.com>2012-09-04 09:38:48 +0300
committerAlex Denisov <1101.debian@gmail.com>2012-09-04 09:38:48 +0300
commitb73d4419ea458a2824a35563bcd84d519b2a5516 (patch)
tree0ae1a8544fa3b8a2e34731dfdcd47359498c20fd
parent6b3ce96a19b46b1ca59c3d3002981375d0a98379 (diff)
downloadgitlab-ce-b73d4419ea458a2824a35563bcd84d519b2a5516.tar.gz
json_spec added. Create project via REST API fixed
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock4
-rw-r--r--spec/factories.rb3
-rw-r--r--spec/requests/api/projects_spec.rb62
-rw-r--r--spec/spec_helper.rb1
5 files changed, 22 insertions, 49 deletions
diff --git a/Gemfile b/Gemfile
index b0724fadf5b..33f9cf4c1ea 100644
--- a/Gemfile
+++ b/Gemfile
@@ -117,6 +117,7 @@ group :test do
gem 'email_spec'
gem 'resque_spec'
gem "webmock"
+ gem 'json_spec'
end
group :production do
diff --git a/Gemfile.lock b/Gemfile.lock
index 7ec37f59dfc..ae85a43a7bf 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -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
diff --git a/spec/factories.rb b/spec/factories.rb
index 2e4acf39461..95c919fd915 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -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
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index cdab2657012..43c44974bb0 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -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 {
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index d381b3f1e2e..30a213bac18 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -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