dune-api 1.0.1

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.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +35 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +19 -0
  6. data/CHANGELOG.md +48 -0
  7. data/Gemfile +7 -0
  8. data/Gemfile.lock +601 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +19 -0
  11. data/README.md.backup +61 -0
  12. data/Rakefile +2 -0
  13. data/apiary.apib +1769 -0
  14. data/app/constraints/dune/api/api_constraint.rb +17 -0
  15. data/app/controllers/dune/api/base_controller.rb +68 -0
  16. data/app/controllers/dune/api/v1/channels/members_controller.rb +33 -0
  17. data/app/controllers/dune/api/v1/channels_controller.rb +73 -0
  18. data/app/controllers/dune/api/v1/investments_controller.rb +70 -0
  19. data/app/controllers/dune/api/v1/press_assets_controller.rb +38 -0
  20. data/app/controllers/dune/api/v1/projects_controller.rb +76 -0
  21. data/app/controllers/dune/api/v1/rewards_controller.rb +9 -0
  22. data/app/controllers/dune/api/v1/sessions_controller.rb +27 -0
  23. data/app/controllers/dune/api/v1/tags_controller.rb +37 -0
  24. data/app/controllers/dune/api/v1/users_controller.rb +26 -0
  25. data/app/models/dune/api/access_token.rb +24 -0
  26. data/app/models/dune/api/investment.rb +14 -0
  27. data/app/models/dune/api/project.rb +23 -0
  28. data/app/models/dune/api/user_concern.rb +11 -0
  29. data/app/serializers/channel_member_serializer.rb +7 -0
  30. data/app/serializers/channel_serializer.rb +34 -0
  31. data/app/serializers/dune/api/investment_serializer.rb +44 -0
  32. data/app/serializers/dune/api/project_serializer.rb +86 -0
  33. data/app/serializers/press_asset_serializer.rb +11 -0
  34. data/app/serializers/reward_serializer.rb +13 -0
  35. data/app/serializers/tag_serializer.rb +10 -0
  36. data/app/serializers/user_serializer.rb +46 -0
  37. data/bin/rails +8 -0
  38. data/config/initializers/mime_types.rb +1 -0
  39. data/config/routes.rb +42 -0
  40. data/db/migrate/20140624141405_create_dune_api_access_tokens.rb +11 -0
  41. data/dune-api.gemspec +28 -0
  42. data/lib/dune/api.rb +12 -0
  43. data/lib/dune/api/engine.rb +11 -0
  44. data/lib/dune/api/paginated_controller.rb +19 -0
  45. data/lib/dune/api/version.rb +5 -0
  46. data/spec/constraints/neighborly/api/api_constraint_spec.rb +50 -0
  47. data/spec/controllers/neighborly/api/v1/channels/members_controller_spec.rb +82 -0
  48. data/spec/controllers/neighborly/api/v1/channels_controller_spec.rb +188 -0
  49. data/spec/controllers/neighborly/api/v1/investments_controller_spec.rb +178 -0
  50. data/spec/controllers/neighborly/api/v1/press_assets_controller_spec.rb +129 -0
  51. data/spec/controllers/neighborly/api/v1/projects_controller_spec.rb +317 -0
  52. data/spec/controllers/neighborly/api/v1/rewards_controller_spec.rb +28 -0
  53. data/spec/controllers/neighborly/api/v1/sessions_controller_spec.rb +67 -0
  54. data/spec/controllers/neighborly/api/v1/tags_controller_spec.rb +143 -0
  55. data/spec/controllers/neighborly/api/v1/users_controller_spec.rb +43 -0
  56. data/spec/factories.rb +78 -0
  57. data/spec/fixtures/image.png +0 -0
  58. data/spec/models/neighborly/api/investment_spec.rb +33 -0
  59. data/spec/models/neighborly/api/user_concern_spec.rb +33 -0
  60. data/spec/spec_helper.rb +43 -0
  61. data/spec/support/shared_examples.rb +96 -0
  62. metadata +219 -0
@@ -0,0 +1,96 @@
1
+ RSpec.shared_context 'authorized context', authorized: true do
2
+ before do
3
+ request.env['HTTP_AUTHORIZATION'] = "Token token=#{valid_access_token.code}"
4
+ end
5
+
6
+ let(:valid_access_token) { FactoryGirl.create(:access_token, user: user) }
7
+ let!(:user) do
8
+ if defined?(super)
9
+ super()
10
+ else
11
+ defined?(admin_user) ? admin_user : FactoryGirl.create(:user)
12
+ end
13
+ end
14
+
15
+ it_behaves_like 'checking authorization'
16
+ end
17
+
18
+ RSpec.shared_context 'admin user context', admin: true do
19
+ let!(:admin_user) do
20
+ defined?(super) ? super() : FactoryGirl.create(:user, admin: true)
21
+ end
22
+
23
+ it_behaves_like 'checking admin authorization'
24
+ end
25
+
26
+ RSpec.shared_examples 'checking authorization' do
27
+ context 'when access_token is provided' do
28
+ context 'and is not valid' do
29
+ it 'responds with 401 when inexistant' do
30
+ request.env['HTTP_AUTHORIZATION'] = 'Token token=invalid-access-token'
31
+ do_request
32
+ expect(response.status).to eql(401)
33
+ end
34
+
35
+ it 'responds with 401 when expired' do
36
+ valid_access_token.expire!
37
+ request.env['HTTP_AUTHORIZATION'] = "Token token=#{valid_access_token.code}"
38
+ do_request
39
+ expect(response.status).to eql(401)
40
+ end
41
+ end
42
+ end
43
+
44
+ context 'when access_token is not provided' do
45
+ before do
46
+ request.env['HTTP_AUTHORIZATION'] = nil
47
+ end
48
+
49
+ it 'responds with 401' do
50
+ do_request
51
+ expect(response.status).to eql(401)
52
+ end
53
+ end
54
+ end
55
+
56
+ RSpec.shared_examples 'checking admin authorization' do
57
+ context 'when user is not admin' do
58
+ let!(:user) do
59
+ defined?(not_admin_user) ? not_admin_user : FactoryGirl.create(:user)
60
+ end
61
+
62
+ it 'responds with 401' do
63
+ do_request
64
+ expect(response.status).to eql(401)
65
+ end
66
+ end
67
+ end
68
+
69
+ RSpec.shared_examples 'paginating results' do
70
+ let(:resource_name) do
71
+ described_class.name.demodulize.sub('Controller', '').underscore
72
+ end
73
+
74
+ describe 'pagination' do
75
+ before do
76
+ FactoryGirl.create_list(
77
+ resource_name.downcase.singularize.to_sym,
78
+ 26
79
+ )
80
+ do_request
81
+ end
82
+
83
+ it 'limits long collections' do
84
+ expect(
85
+ parsed_response.fetch(resource_name.downcase.pluralize).size
86
+ ).to eql(25)
87
+ end
88
+
89
+ it 'responds with its meta information' do
90
+ meta = parsed_response.fetch('meta')
91
+ expect(meta['page']).to eql(1)
92
+ expect(meta['total']).to eql(27)
93
+ expect(meta['total_pages']).to eql(2)
94
+ end
95
+ end
96
+ end
metadata ADDED
@@ -0,0 +1,219 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dune-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pierre Legrand
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: has_scope
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: kaminari
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pundit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: active_model_serializers
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.8.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.8.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '10.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '10.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ description: This is the implementation of Dune API from neighborly api
112
+ email:
113
+ - legrand.work@gmail.com
114
+ executables:
115
+ - rails
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - .gitignore
120
+ - .gitmodules
121
+ - .rspec
122
+ - .travis.yml
123
+ - CHANGELOG.md
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - LICENSE.txt
127
+ - README.md
128
+ - README.md.backup
129
+ - Rakefile
130
+ - apiary.apib
131
+ - app/constraints/dune/api/api_constraint.rb
132
+ - app/controllers/dune/api/base_controller.rb
133
+ - app/controllers/dune/api/v1/channels/members_controller.rb
134
+ - app/controllers/dune/api/v1/channels_controller.rb
135
+ - app/controllers/dune/api/v1/investments_controller.rb
136
+ - app/controllers/dune/api/v1/press_assets_controller.rb
137
+ - app/controllers/dune/api/v1/projects_controller.rb
138
+ - app/controllers/dune/api/v1/rewards_controller.rb
139
+ - app/controllers/dune/api/v1/sessions_controller.rb
140
+ - app/controllers/dune/api/v1/tags_controller.rb
141
+ - app/controllers/dune/api/v1/users_controller.rb
142
+ - app/models/dune/api/access_token.rb
143
+ - app/models/dune/api/investment.rb
144
+ - app/models/dune/api/project.rb
145
+ - app/models/dune/api/user_concern.rb
146
+ - app/serializers/channel_member_serializer.rb
147
+ - app/serializers/channel_serializer.rb
148
+ - app/serializers/dune/api/investment_serializer.rb
149
+ - app/serializers/dune/api/project_serializer.rb
150
+ - app/serializers/press_asset_serializer.rb
151
+ - app/serializers/reward_serializer.rb
152
+ - app/serializers/tag_serializer.rb
153
+ - app/serializers/user_serializer.rb
154
+ - bin/rails
155
+ - config/initializers/mime_types.rb
156
+ - config/routes.rb
157
+ - db/migrate/20140624141405_create_dune_api_access_tokens.rb
158
+ - dune-api.gemspec
159
+ - lib/dune/api.rb
160
+ - lib/dune/api/engine.rb
161
+ - lib/dune/api/paginated_controller.rb
162
+ - lib/dune/api/version.rb
163
+ - spec/constraints/neighborly/api/api_constraint_spec.rb
164
+ - spec/controllers/neighborly/api/v1/channels/members_controller_spec.rb
165
+ - spec/controllers/neighborly/api/v1/channels_controller_spec.rb
166
+ - spec/controllers/neighborly/api/v1/investments_controller_spec.rb
167
+ - spec/controllers/neighborly/api/v1/press_assets_controller_spec.rb
168
+ - spec/controllers/neighborly/api/v1/projects_controller_spec.rb
169
+ - spec/controllers/neighborly/api/v1/rewards_controller_spec.rb
170
+ - spec/controllers/neighborly/api/v1/sessions_controller_spec.rb
171
+ - spec/controllers/neighborly/api/v1/tags_controller_spec.rb
172
+ - spec/controllers/neighborly/api/v1/users_controller_spec.rb
173
+ - spec/factories.rb
174
+ - spec/fixtures/image.png
175
+ - spec/models/neighborly/api/investment_spec.rb
176
+ - spec/models/neighborly/api/user_concern_spec.rb
177
+ - spec/spec_helper.rb
178
+ - spec/support/shared_examples.rb
179
+ homepage: https://github.com/FromUte/dune-api
180
+ licenses:
181
+ - MIT
182
+ metadata: {}
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - '>='
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - '>='
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ requirements: []
198
+ rubyforge_project:
199
+ rubygems_version: 2.0.14
200
+ signing_key:
201
+ specification_version: 4
202
+ summary: dune API
203
+ test_files:
204
+ - spec/constraints/neighborly/api/api_constraint_spec.rb
205
+ - spec/controllers/neighborly/api/v1/channels/members_controller_spec.rb
206
+ - spec/controllers/neighborly/api/v1/channels_controller_spec.rb
207
+ - spec/controllers/neighborly/api/v1/investments_controller_spec.rb
208
+ - spec/controllers/neighborly/api/v1/press_assets_controller_spec.rb
209
+ - spec/controllers/neighborly/api/v1/projects_controller_spec.rb
210
+ - spec/controllers/neighborly/api/v1/rewards_controller_spec.rb
211
+ - spec/controllers/neighborly/api/v1/sessions_controller_spec.rb
212
+ - spec/controllers/neighborly/api/v1/tags_controller_spec.rb
213
+ - spec/controllers/neighborly/api/v1/users_controller_spec.rb
214
+ - spec/factories.rb
215
+ - spec/fixtures/image.png
216
+ - spec/models/neighborly/api/investment_spec.rb
217
+ - spec/models/neighborly/api/user_concern_spec.rb
218
+ - spec/spec_helper.rb
219
+ - spec/support/shared_examples.rb