social_snippet-registry_core 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzExN2MyNmYyM2ZmN2IyY2ZjZDI4Y2RhOTcxYzQ1ZGU4MWQ5OTI2Mw==
4
+ MDdmODRmYmM0MDZmYjI5MTJkMzQ4MDgwNjkzNDNiNTkyNTc1YzZjNQ==
5
5
  data.tar.gz: !binary |-
6
- OTRjMzhlYzc0ZTI4ODQwY2Q2ODM0ZDAxNmViYmU3M2ZiOWIwNjg0Zg==
6
+ YjlmZTM5MzlhNmE3Y2VkZjNmNjY0ZDVkZjY4ZDVkMTk1YjY5NTY1Yw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTljMmRjYTE3N2ZjZWIwYWM4ZDgxYzI2ZWY4MTBkYWM4ODU0MGVjMzg2Yzk4
10
- MWFjOGFkOGI5ZjJhMmFlYWQ1MjZiZTE2NzljZTg5Y2M2ODRmNGViZjc0Mjdj
11
- MmRlMjJhNjZhYTIyOTJlZThlMjQyY2YxMmE1MzNhMmY5ZmM0MWE=
9
+ YTIwYjI5Y2NkYzFiNjg5NGQyMTk4MzVkOGViNGQ2MGEzZTAwNDk4MzZiZDAy
10
+ MGQ0MWEyMmQ0YTljOGQ3MDBhYjliMTVmM2JmMzllZDJmYmU2ZTc5Y2EzY2Q2
11
+ NTEwODFjZDQ4ZmFmODlhYjY2ZmI0ZTg2NDg4YjM0MGNhNDQ2Yzg=
12
12
  data.tar.gz: !binary |-
13
- ZmJlMjkyMThhZjMxZGU3MDQ3ZjE1MDVmZmZlMGU3ZWZiZWFhNDJmZDllMDBi
14
- Mzg2YTAxMGVmZWM2MGZkYjg5MGM3MjcyYThhYTJjZmJkNmNmNzY0ZmM0MDBh
15
- MjllYmE4ZDBkMDNlYzJlZjk0YTUxZGJjYTY5Njg0ZDk5NmRjYzQ=
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
@@ -8,6 +8,7 @@ group :test do
8
8
  gem "database_cleaner"
9
9
  gem "factory_girl"
10
10
  gem "rack-test"
11
+ gem "mongoid-tree"
11
12
  end
12
13
 
13
14
  group :debug do
@@ -1,4 +1,4 @@
1
- class Repository
1
+ class SocialSnippet::Registry::WebAPI::Repository
2
2
 
3
3
  include Mongoid::Document
4
4
  include Mongoid::Timestamps # adds created_at and updated_at fields
@@ -1,4 +1,4 @@
1
- class UserAccount
1
+ class SocialSnippet::Registry::WebAPI::UserAccount
2
2
 
3
3
  include Mongoid::Document
4
4
  include Mongoid::Timestamps # adds created_at and updated_at fields
@@ -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,5 +1,5 @@
1
1
  module SocialSnippet
2
2
  module RegistryCore
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -1,232 +1,236 @@
1
1
  require "spec_helper"
2
2
 
3
- describe SocialSnippet::Registry::WebAPI::WebAPIv0 do
3
+ module SocialSnippet::Registry::WebAPI
4
4
 
5
- describe "repository_controller" do
5
+ describe WebAPIv0 do
6
6
 
7
- app SocialSnippet::Registry::WebAPI::WebAPIv0
7
+ describe "repository_controller" do
8
8
 
9
- let(:api_version) { '/v0' }
9
+ app WebAPIv0
10
10
 
11
- context "add my-repo" do
11
+ let(:api_version) { '/v0' }
12
12
 
13
- before do
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
- FactoryGirl.create "my-repo"
23
- end # prepare my-repo
24
-
25
- context "get repositories/my-repo" do
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
- before { get "#{api_version}/repositories/my-repo" }
28
- it { expect(last_response).to be_ok }
24
+ FactoryGirl.create "my-repo"
25
+ end # prepare my-repo
29
26
 
30
- context "check result" do
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
- end
29
+ before { get "#{api_version}/repositories/my-repo" }
30
+ it { expect(last_response).to be_ok }
39
31
 
40
- context "get repositories" do
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
- it { expect(last_response).to be_ok }
42
+ context "get repositories" do
47
43
 
48
- context "check result json" do
49
- let(:result) { JSON.parse(last_response.body) }
50
- it { expect(result.length).to eq 1 }
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
- end # get repositories
48
+ it { expect(last_response).to be_ok }
57
49
 
58
- context "add new-repo" do
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
- context "post repositories" do
58
+ end # get repositories
61
59
 
62
- let(:new_repo_url_raw) { "git://github.com/user/new-repo" }
63
- let(:new_repo_url) { URI.encode_www_form_component new_repo_url_raw }
60
+ context "add new-repo" do
64
61
 
65
- before do
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
- context "post by json params" do
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
- # TODO: check without token
88
- header "X-CSRF-TOKEN", "dummy-token"
89
- data = {
90
- "url" => new_repo_url_raw,
91
- }
92
- post(
93
- "#{api_version}/repositories",
94
- data.to_json,
95
- {
96
- "CONTENT_TYPE" => "application/json",
97
- "rack.session" => {
98
- :csrf => "dummy-token",
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
- it "", :current => true do; end # TODO: remove
106
+ it "", :current => true do; end # TODO: remove
105
107
 
106
- it { expect(last_response).to be_ok }
108
+ it { expect(last_response).to be_ok }
107
109
 
108
- context "check result model" do
110
+ context "check result model" do
109
111
 
110
- let(:repo) { Repository.find_by(:name => "new-repo") }
111
- it { expect(repo.name).to eq "new-repo" }
112
- it { expect(repo.url).to eq "git://github.com/user/new-repo.git" }
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
- end # check result model
116
+ end # check result model
115
117
 
116
- context "with query" do
118
+ context "with query" do
117
119
 
118
- context "get repositories?q=new" do
120
+ context "get repositories?q=new" do
119
121
 
120
- before { get "#{api_version}/repositories?q=new" }
122
+ before { get "#{api_version}/repositories?q=new" }
121
123
 
122
- it { expect(last_response).to be_ok }
124
+ it { expect(last_response).to be_ok }
123
125
 
124
- context "check result json" do
125
- let(:result) { JSON.parse(last_response.body) }
126
- it { expect(result.length).to eq 1 }
127
- it { expect(result[0]["name"]).to eq "new-repo" }
128
- it { expect(result[0]["url"]).to eq "git://github.com/user/new-repo.git" }
129
- it { expect(result[0]["desc"]).to eq "This is new repo" }
130
- end
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
- end # get repositories?q=new
134
+ end # get repositories?q=new
133
135
 
134
- context "get repositories?q=my" do
136
+ context "get repositories?q=my" do
135
137
 
136
- before { get "#{api_version}/repositories?q=my" }
138
+ before { get "#{api_version}/repositories?q=my" }
137
139
 
138
- it { expect(last_response).to be_ok }
140
+ it { expect(last_response).to be_ok }
139
141
 
140
- context "check result json" do
141
- let(:result) { JSON.parse(last_response.body) }
142
- it { expect(result.length).to eq 1 }
143
- it { expect(result[0]["name"]).to eq "my-repo" }
144
- it { expect(result[0]["url"]).to eq "git://github.com/user/my-repo.git" }
145
- it { expect(result[0]["desc"]).to eq "This is my repository" }
146
- end
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
- end # get repositories?q=new
150
+ end # get repositories?q=new
149
151
 
150
- end # with query
152
+ end # with query
151
153
 
152
- end # post by query params
154
+ end # post by query params
153
155
 
154
- context "post by query params" do
156
+ context "post by query params" do
155
157
 
156
- before do
157
- # TODO: check without token
158
- header "X-CSRF-TOKEN", "dummy-token"
159
- post(
160
- "#{api_version}/repositories?url=#{new_repo_url}",
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
- end
165
+ {
166
+ "rack.session" => {
167
+ :csrf => "dummy-token",
168
+ },
169
+ }
170
+ )
171
+ end
170
172
 
171
- it { expect(last_response).to be_ok }
173
+ it { expect(last_response).to be_ok }
172
174
 
173
- context "check result model" do
175
+ context "check result model" do
174
176
 
175
- let(:repo) do
176
- Repository.find_by(:name => "new-repo")
177
- end
177
+ let(:repo) do
178
+ Repository.find_by(:name => "new-repo")
179
+ end
178
180
 
179
- it { expect(repo.name).to eq "new-repo" }
180
- it { expect(repo.url).to eq "git://github.com/user/new-repo.git" }
181
- it { expect(repo.dependencies).to_not be_empty }
182
- it { expect(repo.dependencies.length).to eq 1 }
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
- end # check result model
186
+ end # check result model
185
187
 
186
- context "with query" do
188
+ context "with query" do
187
189
 
188
- context "get repositories?q=new" do
190
+ context "get repositories?q=new" do
189
191
 
190
- before { get "#{api_version}/repositories?q=new" }
192
+ before { get "#{api_version}/repositories?q=new" }
191
193
 
192
- it { expect(last_response).to be_ok }
194
+ it { expect(last_response).to be_ok }
193
195
 
194
- context "check result json" do
195
- let(:result) { JSON.parse(last_response.body) }
196
- it { expect(result.length).to eq 1 }
197
- it { expect(result[0]["name"]).to eq "new-repo" }
198
- it { expect(result[0]["url"]).to eq "git://github.com/user/new-repo.git" }
199
- it { expect(result[0]["desc"]).to eq "This is new repo" }
200
- end
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
- end # get repositories?q=new
204
+ end # get repositories?q=new
203
205
 
204
- context "get repositories?q=my" do
206
+ context "get repositories?q=my" do
205
207
 
206
- before { get "#{api_version}/repositories?q=my" }
208
+ before { get "#{api_version}/repositories?q=my" }
207
209
 
208
- it { expect(last_response).to be_ok }
210
+ it { expect(last_response).to be_ok }
209
211
 
210
- context "check result json" do
211
- let(:result) { JSON.parse(last_response.body) }
212
- it { expect(result.length).to eq 1 }
213
- it { expect(result[0]["name"]).to eq "my-repo" }
214
- it { expect(result[0]["url"]).to eq "git://github.com/user/my-repo.git" }
215
- it { expect(result[0]["desc"]).to eq "This is my repository" }
216
- end
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 # get repositories?q=new
222
+ end # with query
219
223
 
220
- end # with query
224
+ end # post by query params
221
225
 
222
- end # post by query params
226
+ end # post repositories
223
227
 
224
- end # post repositories
228
+ end # add new-repo
225
229
 
226
- end # add new-repo
230
+ end # add my-repo
227
231
 
228
- end # add my-repo
232
+ end # repositories_controller
229
233
 
230
- end # repositories_controller
234
+ end # WebAPIv0
231
235
 
232
- end # SocialSnippet::Registry::WebAPI::Versions::WebAPIv0
236
+ end # SocialSnippet::Registry::WebAPI
@@ -1,72 +1,75 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Repository do
3
+ module SocialSnippet::Registry::WebAPI
4
4
 
5
- describe "#to_object" do
5
+ describe Repository do
6
6
 
7
- context "create model" do
7
+ describe "#to_object" do
8
8
 
9
- let(:model) do
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
- context "call to_object" do
18
- let(:result) { model.to_object }
19
- it { expect(result[:name]).to eq "my-repo" }
20
- it { expect(result[:desc]).to eq "thisisdesc" }
21
- it { expect(result[:url]).to eq "git://url/to/git/repo" }
22
- end # call to_object
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
- end # to_object
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
- describe "#update_by_snippet_json" do
26
+ end # create model
29
27
 
30
- context "create model" do
28
+ end # to_object
31
29
 
32
- let(:model) do
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 repo" do
32
+ context "create model" do
41
33
 
42
- let(:json_obj) do
43
- {
44
- "name" => "new-repo",
45
- "desc" => "this is new desc",
46
- "dependencies" => {
47
- "my-repo" => "1.0.0",
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 "call update_by" do
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
- before { model.update_by_snippet_json(json_obj) }
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
- end # update_by_real_repo
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.3
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: 2014-12-31 00:00:00.000000000 Z
11
+ date: 2015-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler