Commit b73d4419ea458a2824a35563bcd84d519b2a5516
1 parent
6b3ce96a
Exists in
master
and in
4 other branches
json_spec added. Create project via REST API fixed
Showing
5 changed files
with
22 additions
and
49 deletions
Show diff stats
Gemfile
Gemfile.lock
| ... | ... | @@ -207,6 +207,9 @@ GEM |
| 207 | 207 | jquery-rails |
| 208 | 208 | railties (>= 3.1.0) |
| 209 | 209 | json (1.7.5) |
| 210 | + json_spec (1.0.3) | |
| 211 | + multi_json (~> 1.0) | |
| 212 | + rspec (~> 2.0) | |
| 210 | 213 | kaminari (0.14.0) |
| 211 | 214 | actionpack (>= 3.0.0) |
| 212 | 215 | activesupport (>= 3.0.0) |
| ... | ... | @@ -406,6 +409,7 @@ DEPENDENCIES |
| 406 | 409 | httparty |
| 407 | 410 | jquery-rails (= 2.0.2) |
| 408 | 411 | jquery-ui-rails (= 0.5.0) |
| 412 | + json_spec | |
| 409 | 413 | kaminari |
| 410 | 414 | launchy |
| 411 | 415 | letter_opener | ... | ... |
spec/factories.rb
spec/requests/api/projects_spec.rb
| ... | ... | @@ -39,55 +39,19 @@ describe Gitlab::API do |
| 39 | 39 | }.should change{Project.count}.by(1) |
| 40 | 40 | end |
| 41 | 41 | it "should create new project" do |
| 42 | - expect { | |
| 43 | - name = "foo" | |
| 44 | - path = "bar" | |
| 45 | - code = "bazz" | |
| 46 | - description = "fuu project" | |
| 47 | - default_branch = "default_branch" | |
| 48 | - issues_enabled = false | |
| 49 | - wall_enabled = false | |
| 50 | - merge_requests_enabled = false | |
| 51 | - wiki_enabled = false | |
| 52 | - post api("/projects", user), { | |
| 53 | - code: code, | |
| 54 | - path: path, | |
| 55 | - name: name, | |
| 56 | - description: description, | |
| 57 | - default_branch: default_branch, | |
| 58 | - issues_enabled: issues_enabled, | |
| 59 | - wall_enabled: wall_enabled, | |
| 60 | - merge_requests_enabled: merge_requests_enabled, | |
| 61 | - wiki_enabled: wiki_enabled | |
| 62 | - } | |
| 63 | - response.status.should == 201 | |
| 64 | - json_response["name"].should == name | |
| 65 | - json_response["path"].should == path | |
| 66 | - json_response["code"].should == code | |
| 67 | - json_response["description"].should == description | |
| 68 | - json_response["default_branch"].should == default_branch | |
| 69 | - json_response["issues_enabled"].should == issues_enabled | |
| 70 | - json_response["wall_enabled"].should == wall_enabled | |
| 71 | - json_response["merge_requests_enabled"].should == merge_requests_enabled | |
| 72 | - json_response["wiki_enabled"].should == wiki_enabled | |
| 73 | - }.should change{Project.count}.by(1) | |
| 74 | - end | |
| 75 | - it "should create new projects within all parameters" do | |
| 76 | - expect { | |
| 77 | - name = "foo" | |
| 78 | - path = "bar" | |
| 79 | - code = "bazz" | |
| 80 | - post api("/projects", user), { | |
| 81 | - code: code, | |
| 82 | - path: path, | |
| 83 | - name: name | |
| 84 | - } | |
| 85 | - response.status.should == 201 | |
| 86 | - json_response["name"].should == name | |
| 87 | - json_response["path"].should == path | |
| 88 | - json_response["code"].should == code | |
| 89 | - }.should change{Project.count}.by(1) | |
| 90 | - | |
| 42 | + attributes = Factory.attributes(:project, | |
| 43 | + name: "foo", | |
| 44 | + path: "bar", | |
| 45 | + code: "bazz", | |
| 46 | + description: "foo project", | |
| 47 | + default_branch: "default_branch", | |
| 48 | + issues_enabled: false, | |
| 49 | + wall_enabled: false, | |
| 50 | + merge_requests_enabled: false, | |
| 51 | + wiki_enabled: false) | |
| 52 | + post api("/projects", user), attributes | |
| 53 | + response.status.should == 201 | |
| 54 | + response.body.should be_json_eql(attributes.to_json).excluding("owner", "private") | |
| 91 | 55 | end |
| 92 | 56 | it "should not create project without name" do |
| 93 | 57 | expect { | ... | ... |
spec/spec_helper.rb
| ... | ... | @@ -28,6 +28,7 @@ RSpec.configure do |config| |
| 28 | 28 | config.include LoginHelpers, type: :request |
| 29 | 29 | config.include GitoliteStub |
| 30 | 30 | config.include FactoryGirl::Syntax::Methods |
| 31 | + config.include JsonSpec::Helpers | |
| 31 | 32 | |
| 32 | 33 | # If you're not using ActiveRecord, or you'd prefer not to run each of your |
| 33 | 34 | # examples within a transaction, remove the following line or assign false | ... | ... |