social_snippet-registry_core 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +7 -2
- data/Gemfile +1 -0
- data/lib/social_snippet/registry/webapi/models/repository.rb +1 -1
- data/lib/social_snippet/registry/webapi/models/user_account.rb +1 -1
- data/lib/social_snippet/registry_core/config_helpers.rb +1 -1
- data/lib/social_snippet/registry_core/version.rb +1 -1
- data/spec/webapi/controllers/v0/repositories_controller_spec.rb +167 -163
- data/spec/webapi/models/repository_spec.rb +52 -49
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDdmODRmYmM0MDZmYjI5MTJkMzQ4MDgwNjkzNDNiNTkyNTc1YzZjNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjlmZTM5MzlhNmE3Y2VkZjNmNjY0ZDVkZjY4ZDVkMTk1YjY5NTY1Yw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTIwYjI5Y2NkYzFiNjg5NGQyMTk4MzVkOGViNGQ2MGEzZTAwNDk4MzZiZDAy
|
10
|
+
MGQ0MWEyMmQ0YTljOGQ3MDBhYjliMTVmM2JmMzllZDJmYmU2ZTc5Y2EzY2Q2
|
11
|
+
NTEwODFjZDQ4ZmFmODlhYjY2ZmI0ZTg2NDg4YjM0MGNhNDQ2Yzg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmYzYmZkNjRiOTFlOTJjY2ZlYWRlOGI4NDZiZmI2NmUyNTRhMzlkNWZjMTU2
|
14
|
+
NzFkZWJiMjgwMmQzYjhkMmU3NWM2MWYzN2MzN2U1ZjYzMGZkNDI2MGNiMDZh
|
15
|
+
NjdkNjM4ZjkwYjI5YmI0MGQ3ZWQ5M2MyYTQ3ZDYzY2M0MzAxNDQ=
|
data/.travis.yml
CHANGED
@@ -10,13 +10,18 @@ services:
|
|
10
10
|
- redis-server
|
11
11
|
- memcached
|
12
12
|
|
13
|
-
bundler_args: "--without production:debug --jobs 4 --retry 3"
|
14
|
-
|
15
13
|
sudo: false
|
16
14
|
|
15
|
+
install:
|
16
|
+
- bundle install --without debug --jobs 4 --retry 3 --path vendor/bundle
|
17
|
+
|
17
18
|
script:
|
18
19
|
- bundle exec rake spec
|
19
20
|
|
21
|
+
cache:
|
22
|
+
directories:
|
23
|
+
- vendor/bundle
|
24
|
+
|
20
25
|
deploy:
|
21
26
|
provider: rubygems
|
22
27
|
api_key:
|
data/Gemfile
CHANGED
@@ -31,7 +31,7 @@ module SocialSnippet::RegistryCore::ConfigHelpers
|
|
31
31
|
logger.info "Enable User Access Control: #{self}"
|
32
32
|
|
33
33
|
register ::Padrino::Admin::AccessControl
|
34
|
-
set :admin_model, "UserAccount"
|
34
|
+
set :admin_model, "::SocialSnippet::Registry::WebAPI::UserAccount"
|
35
35
|
set :login_page, :login
|
36
36
|
enable :authentication
|
37
37
|
enable :store_location
|
@@ -1,232 +1,236 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
3
|
+
module SocialSnippet::Registry::WebAPI
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe WebAPIv0 do
|
6
6
|
|
7
|
-
|
7
|
+
describe "repository_controller" do
|
8
8
|
|
9
|
-
|
9
|
+
app WebAPIv0
|
10
10
|
|
11
|
-
|
11
|
+
let(:api_version) { '/v0' }
|
12
12
|
|
13
|
-
|
14
|
-
FactoryGirl.define do
|
15
|
-
factory "my-repo", :class => Repository do
|
16
|
-
name "my-repo"
|
17
|
-
desc "This is my repository"
|
18
|
-
url "git://github.com/user/my-repo.git"
|
19
|
-
end
|
20
|
-
end # define my-repo
|
13
|
+
context "add my-repo" do
|
21
14
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
before do
|
16
|
+
FactoryGirl.define do
|
17
|
+
factory "my-repo", :class => Repository do
|
18
|
+
name "my-repo"
|
19
|
+
desc "This is my repository"
|
20
|
+
url "git://github.com/user/my-repo.git"
|
21
|
+
end
|
22
|
+
end # define my-repo
|
26
23
|
|
27
|
-
|
28
|
-
|
24
|
+
FactoryGirl.create "my-repo"
|
25
|
+
end # prepare my-repo
|
29
26
|
|
30
|
-
context "
|
31
|
-
let(:result) { JSON.parse(last_response.body) }
|
32
|
-
it { expect(result["name"]).to eq "my-repo" }
|
33
|
-
it { expect(result["url"]).to eq "git://github.com/user/my-repo.git" }
|
34
|
-
it { expect(result["desc"]).to eq "This is my repository" }
|
35
|
-
it { expect(result["dependencies"]).to be_empty }
|
36
|
-
end
|
27
|
+
context "get repositories/my-repo" do
|
37
28
|
|
38
|
-
|
29
|
+
before { get "#{api_version}/repositories/my-repo" }
|
30
|
+
it { expect(last_response).to be_ok }
|
39
31
|
|
40
|
-
|
32
|
+
context "check result" do
|
33
|
+
let(:result) { JSON.parse(last_response.body) }
|
34
|
+
it { expect(result["name"]).to eq "my-repo" }
|
35
|
+
it { expect(result["url"]).to eq "git://github.com/user/my-repo.git" }
|
36
|
+
it { expect(result["desc"]).to eq "This is my repository" }
|
37
|
+
it { expect(result["dependencies"]).to be_empty }
|
38
|
+
end
|
41
39
|
|
42
|
-
before do
|
43
|
-
get "#{api_version}/repositories"
|
44
40
|
end
|
45
41
|
|
46
|
-
|
42
|
+
context "get repositories" do
|
47
43
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
it { expect(result[0]["name"]).to eq "my-repo" }
|
52
|
-
it { expect(result[0]["url"]).to eq "git://github.com/user/my-repo.git" }
|
53
|
-
it { expect(result[0]["desc"]).to eq "This is my repository" }
|
54
|
-
end # check result json
|
44
|
+
before do
|
45
|
+
get "#{api_version}/repositories"
|
46
|
+
end
|
55
47
|
|
56
|
-
|
48
|
+
it { expect(last_response).to be_ok }
|
57
49
|
|
58
|
-
|
50
|
+
context "check result json" do
|
51
|
+
let(:result) { JSON.parse(last_response.body) }
|
52
|
+
it { expect(result.length).to eq 1 }
|
53
|
+
it { expect(result[0]["name"]).to eq "my-repo" }
|
54
|
+
it { expect(result[0]["url"]).to eq "git://github.com/user/my-repo.git" }
|
55
|
+
it { expect(result[0]["desc"]).to eq "This is my repository" }
|
56
|
+
end # check result json
|
59
57
|
|
60
|
-
|
58
|
+
end # get repositories
|
61
59
|
|
62
|
-
|
63
|
-
let(:new_repo_url) { URI.encode_www_form_component new_repo_url_raw }
|
60
|
+
context "add new-repo" do
|
64
61
|
|
65
|
-
|
66
|
-
allow_any_instance_of(::SocialSnippet::Registry::WebAPI::WebAPIv0).to receive(:create_fetcher) do
|
67
|
-
class Dummy; end
|
68
|
-
dummy = Dummy.new
|
69
|
-
allow(dummy).to receive(:snippet_json) do |_|
|
70
|
-
{
|
71
|
-
"name" => "new-repo",
|
72
|
-
"desc" => "This is new repo",
|
73
|
-
"language" => "C++",
|
74
|
-
"main" => "src",
|
75
|
-
"dependencies" => {
|
76
|
-
"my-repo" => "1.0.0",
|
77
|
-
},
|
78
|
-
}
|
79
|
-
end
|
80
|
-
dummy
|
81
|
-
end
|
82
|
-
end # clone dummy repo
|
62
|
+
context "post repositories" do
|
83
63
|
|
84
|
-
|
64
|
+
let(:new_repo_url_raw) { "git://github.com/user/new-repo" }
|
65
|
+
let(:new_repo_url) { URI.encode_www_form_component new_repo_url_raw }
|
85
66
|
|
86
67
|
before do
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
68
|
+
allow_any_instance_of(WebAPIv0).to receive(:create_fetcher) do
|
69
|
+
class Dummy; end
|
70
|
+
dummy = Dummy.new
|
71
|
+
allow(dummy).to receive(:snippet_json) do |_|
|
72
|
+
{
|
73
|
+
"name" => "new-repo",
|
74
|
+
"desc" => "This is new repo",
|
75
|
+
"language" => "C++",
|
76
|
+
"main" => "src",
|
77
|
+
"dependencies" => {
|
78
|
+
"my-repo" => "1.0.0",
|
79
|
+
},
|
80
|
+
}
|
81
|
+
end
|
82
|
+
dummy
|
83
|
+
end
|
84
|
+
end # clone dummy repo
|
85
|
+
|
86
|
+
context "post by json params" do
|
87
|
+
|
88
|
+
before do
|
89
|
+
# TODO: check without token
|
90
|
+
header "X-CSRF-TOKEN", "dummy-token"
|
91
|
+
data = {
|
92
|
+
"url" => new_repo_url_raw,
|
93
|
+
}
|
94
|
+
post(
|
95
|
+
"#{api_version}/repositories",
|
96
|
+
data.to_json,
|
97
|
+
{
|
98
|
+
"CONTENT_TYPE" => "application/json",
|
99
|
+
"rack.session" => {
|
100
|
+
:csrf => "dummy-token",
|
101
|
+
},
|
99
102
|
},
|
100
|
-
|
101
|
-
|
102
|
-
end
|
103
|
+
)
|
104
|
+
end
|
103
105
|
|
104
|
-
|
106
|
+
it "", :current => true do; end # TODO: remove
|
105
107
|
|
106
|
-
|
108
|
+
it { expect(last_response).to be_ok }
|
107
109
|
|
108
|
-
|
110
|
+
context "check result model" do
|
109
111
|
|
110
|
-
|
111
|
-
|
112
|
-
|
112
|
+
let(:repo) { Repository.find_by(:name => "new-repo") }
|
113
|
+
it { expect(repo.name).to eq "new-repo" }
|
114
|
+
it { expect(repo.url).to eq "git://github.com/user/new-repo.git" }
|
113
115
|
|
114
|
-
|
116
|
+
end # check result model
|
115
117
|
|
116
|
-
|
118
|
+
context "with query" do
|
117
119
|
|
118
|
-
|
120
|
+
context "get repositories?q=new" do
|
119
121
|
|
120
|
-
|
122
|
+
before { get "#{api_version}/repositories?q=new" }
|
121
123
|
|
122
|
-
|
124
|
+
it { expect(last_response).to be_ok }
|
123
125
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
126
|
+
context "check result json" do
|
127
|
+
let(:result) { JSON.parse(last_response.body) }
|
128
|
+
it { expect(result.length).to eq 1 }
|
129
|
+
it { expect(result[0]["name"]).to eq "new-repo" }
|
130
|
+
it { expect(result[0]["url"]).to eq "git://github.com/user/new-repo.git" }
|
131
|
+
it { expect(result[0]["desc"]).to eq "This is new repo" }
|
132
|
+
end
|
131
133
|
|
132
|
-
|
134
|
+
end # get repositories?q=new
|
133
135
|
|
134
|
-
|
136
|
+
context "get repositories?q=my" do
|
135
137
|
|
136
|
-
|
138
|
+
before { get "#{api_version}/repositories?q=my" }
|
137
139
|
|
138
|
-
|
140
|
+
it { expect(last_response).to be_ok }
|
139
141
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
142
|
+
context "check result json" do
|
143
|
+
let(:result) { JSON.parse(last_response.body) }
|
144
|
+
it { expect(result.length).to eq 1 }
|
145
|
+
it { expect(result[0]["name"]).to eq "my-repo" }
|
146
|
+
it { expect(result[0]["url"]).to eq "git://github.com/user/my-repo.git" }
|
147
|
+
it { expect(result[0]["desc"]).to eq "This is my repository" }
|
148
|
+
end
|
147
149
|
|
148
|
-
|
150
|
+
end # get repositories?q=new
|
149
151
|
|
150
|
-
|
152
|
+
end # with query
|
151
153
|
|
152
|
-
|
154
|
+
end # post by query params
|
153
155
|
|
154
|
-
|
156
|
+
context "post by query params" do
|
155
157
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
},
|
163
|
-
{
|
164
|
-
"rack.session" => {
|
165
|
-
:csrf => "dummy-token",
|
158
|
+
before do
|
159
|
+
# TODO: check without token
|
160
|
+
header "X-CSRF-TOKEN", "dummy-token"
|
161
|
+
post(
|
162
|
+
"#{api_version}/repositories?url=#{new_repo_url}",
|
163
|
+
{
|
166
164
|
},
|
167
|
-
|
168
|
-
|
169
|
-
|
165
|
+
{
|
166
|
+
"rack.session" => {
|
167
|
+
:csrf => "dummy-token",
|
168
|
+
},
|
169
|
+
}
|
170
|
+
)
|
171
|
+
end
|
170
172
|
|
171
|
-
|
173
|
+
it { expect(last_response).to be_ok }
|
172
174
|
|
173
|
-
|
175
|
+
context "check result model" do
|
174
176
|
|
175
|
-
|
176
|
-
|
177
|
-
|
177
|
+
let(:repo) do
|
178
|
+
Repository.find_by(:name => "new-repo")
|
179
|
+
end
|
178
180
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
181
|
+
it { expect(repo.name).to eq "new-repo" }
|
182
|
+
it { expect(repo.url).to eq "git://github.com/user/new-repo.git" }
|
183
|
+
it { expect(repo.dependencies).to_not be_empty }
|
184
|
+
it { expect(repo.dependencies.length).to eq 1 }
|
183
185
|
|
184
|
-
|
186
|
+
end # check result model
|
185
187
|
|
186
|
-
|
188
|
+
context "with query" do
|
187
189
|
|
188
|
-
|
190
|
+
context "get repositories?q=new" do
|
189
191
|
|
190
|
-
|
192
|
+
before { get "#{api_version}/repositories?q=new" }
|
191
193
|
|
192
|
-
|
194
|
+
it { expect(last_response).to be_ok }
|
193
195
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
196
|
+
context "check result json" do
|
197
|
+
let(:result) { JSON.parse(last_response.body) }
|
198
|
+
it { expect(result.length).to eq 1 }
|
199
|
+
it { expect(result[0]["name"]).to eq "new-repo" }
|
200
|
+
it { expect(result[0]["url"]).to eq "git://github.com/user/new-repo.git" }
|
201
|
+
it { expect(result[0]["desc"]).to eq "This is new repo" }
|
202
|
+
end
|
201
203
|
|
202
|
-
|
204
|
+
end # get repositories?q=new
|
203
205
|
|
204
|
-
|
206
|
+
context "get repositories?q=my" do
|
205
207
|
|
206
|
-
|
208
|
+
before { get "#{api_version}/repositories?q=my" }
|
207
209
|
|
208
|
-
|
210
|
+
it { expect(last_response).to be_ok }
|
209
211
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
212
|
+
context "check result json" do
|
213
|
+
let(:result) { JSON.parse(last_response.body) }
|
214
|
+
it { expect(result.length).to eq 1 }
|
215
|
+
it { expect(result[0]["name"]).to eq "my-repo" }
|
216
|
+
it { expect(result[0]["url"]).to eq "git://github.com/user/my-repo.git" }
|
217
|
+
it { expect(result[0]["desc"]).to eq "This is my repository" }
|
218
|
+
end
|
219
|
+
|
220
|
+
end # get repositories?q=new
|
217
221
|
|
218
|
-
end #
|
222
|
+
end # with query
|
219
223
|
|
220
|
-
end #
|
224
|
+
end # post by query params
|
221
225
|
|
222
|
-
end # post
|
226
|
+
end # post repositories
|
223
227
|
|
224
|
-
end #
|
228
|
+
end # add new-repo
|
225
229
|
|
226
|
-
end # add
|
230
|
+
end # add my-repo
|
227
231
|
|
228
|
-
end #
|
232
|
+
end # repositories_controller
|
229
233
|
|
230
|
-
end #
|
234
|
+
end # WebAPIv0
|
231
235
|
|
232
|
-
end # SocialSnippet::Registry::WebAPI
|
236
|
+
end # SocialSnippet::Registry::WebAPI
|
@@ -1,72 +1,75 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
3
|
+
module SocialSnippet::Registry::WebAPI
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe Repository do
|
6
6
|
|
7
|
-
|
7
|
+
describe "#to_object" do
|
8
8
|
|
9
|
-
|
10
|
-
Repository.new(
|
11
|
-
:name => "my-repo",
|
12
|
-
:desc => "thisisdesc",
|
13
|
-
:url => "git://url/to/git/repo",
|
14
|
-
)
|
15
|
-
end
|
9
|
+
context "create model" do
|
16
10
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end # create model
|
11
|
+
let(:model) do
|
12
|
+
Repository.new(
|
13
|
+
:name => "my-repo",
|
14
|
+
:desc => "thisisdesc",
|
15
|
+
:url => "git://url/to/git/repo",
|
16
|
+
)
|
17
|
+
end
|
25
18
|
|
26
|
-
|
19
|
+
context "call to_object" do
|
20
|
+
let(:result) { model.to_object }
|
21
|
+
it { expect(result[:name]).to eq "my-repo" }
|
22
|
+
it { expect(result[:desc]).to eq "thisisdesc" }
|
23
|
+
it { expect(result[:url]).to eq "git://url/to/git/repo" }
|
24
|
+
end # call to_object
|
27
25
|
|
28
|
-
|
26
|
+
end # create model
|
29
27
|
|
30
|
-
|
28
|
+
end # to_object
|
31
29
|
|
32
|
-
|
33
|
-
Repository.new(
|
34
|
-
:name => "my-repo",
|
35
|
-
:desc => "thisisdesc",
|
36
|
-
:url => "git://url/to/git/repo",
|
37
|
-
)
|
38
|
-
end
|
30
|
+
describe "#update_by_snippet_json" do
|
39
31
|
|
40
|
-
context "create
|
32
|
+
context "create model" do
|
41
33
|
|
42
|
-
let(:
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
},
|
49
|
-
}
|
34
|
+
let(:model) do
|
35
|
+
Repository.new(
|
36
|
+
:name => "my-repo",
|
37
|
+
:desc => "thisisdesc",
|
38
|
+
:url => "git://url/to/git/repo",
|
39
|
+
)
|
50
40
|
end
|
51
41
|
|
52
|
-
context "
|
42
|
+
context "create repo" do
|
43
|
+
|
44
|
+
let(:json_obj) do
|
45
|
+
{
|
46
|
+
"name" => "new-repo",
|
47
|
+
"desc" => "this is new desc",
|
48
|
+
"dependencies" => {
|
49
|
+
"my-repo" => "1.0.0",
|
50
|
+
},
|
51
|
+
}
|
52
|
+
end
|
53
53
|
|
54
|
-
|
54
|
+
context "call update_by" do
|
55
|
+
|
56
|
+
before { model.update_by_snippet_json(json_obj) }
|
57
|
+
|
58
|
+
context "call to_object" do
|
59
|
+
let(:result) { model.to_object }
|
60
|
+
it { expect(result[:name]).to eq "my-repo" }
|
61
|
+
it { expect(result[:desc]).to eq "this is new desc" }
|
62
|
+
it { expect(result[:dependencies]).to include "my-repo" }
|
63
|
+
end
|
55
64
|
|
56
|
-
context "call to_object" do
|
57
|
-
let(:result) { model.to_object }
|
58
|
-
it { expect(result[:name]).to eq "my-repo" }
|
59
|
-
it { expect(result[:desc]).to eq "this is new desc" }
|
60
|
-
it { expect(result[:dependencies]).to include "my-repo" }
|
61
65
|
end
|
62
66
|
|
63
67
|
end
|
64
68
|
|
65
|
-
end
|
66
|
-
|
67
|
-
end # create model
|
69
|
+
end # create model
|
68
70
|
|
69
|
-
|
71
|
+
end # update_by_real_repo
|
70
72
|
|
71
|
-
end # Repository
|
73
|
+
end # Repository
|
72
74
|
|
75
|
+
end # SocialSnippet::Registry::WebAPI
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_snippet-registry_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroyuki Sano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|