dune-api 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d02b1babc59f4cbce23dd484b4ce5f4a2013f3b8
4
- data.tar.gz: f1c51b454494a95f2f5b7e56eddc9ac22ad70d01
3
+ metadata.gz: 7d4975afea401af45c6ea6036b7848f41903b4e1
4
+ data.tar.gz: 9a0731bbc16e6de737ff6e86c32a77a0da29b7e8
5
5
  SHA512:
6
- metadata.gz: bec385c88d9191c022c98f7fc8714bea0e2274a4a8f26bb9e9bcc9fd1a0ec82e7107e17596991126982ab4382f84537f628d69524bd0f5f2a4db453a93a0c8fb
7
- data.tar.gz: e15bf25f936b1d0ff2a6f805470101ef2557bc26565ba0691eb5e1c16a3bcb7e99e4f4eb39403655c4d725561b0eb5ba63050b4b88d211cb67563a5fae197790
6
+ metadata.gz: 280572acc54dc4904d969a869c97e8b73a3a110bb0ea8f058e86d7f6019a495c2801cc96aedc770aeab1f04517c83085c652d609ebe8b7d0ab33d998f1ec72cb
7
+ data.tar.gz: 44bbbf7f0ca8643adc4fc04fc4259e5b997621534ca14cb155d6c6c96e00a06fb983ee091b44fefac1b5f72e074cab42fb069f158e6fb18a1b2c17ee3331086a
@@ -16,4 +16,4 @@ script:
16
16
  - 'bundle exec rspec'
17
17
 
18
18
  notifications:
19
- webhooks: https://ci.neighbor.ly/projects/17c44875-7158-4126-a66f-e85c47daad59/status
19
+ webhooks: http://dune-investissement.herokuapp.com/projects/a23a5977-8a4d-4760-a8a4-77755486dc59/status
@@ -30,32 +30,33 @@ PATH
30
30
  rails (~> 4.0)
31
31
 
32
32
  GEM
33
+ remote: https://rubygems.org/
33
34
  remote: https://rubygems.org/
34
35
  specs:
35
36
  CFPropertyList (2.3.0)
36
- actionmailer (4.1.9)
37
- actionpack (= 4.1.9)
38
- actionview (= 4.1.9)
37
+ actionmailer (4.1.7)
38
+ actionpack (= 4.1.7)
39
+ actionview (= 4.1.7)
39
40
  mail (~> 2.5, >= 2.5.4)
40
- actionpack (4.1.9)
41
- actionview (= 4.1.9)
42
- activesupport (= 4.1.9)
41
+ actionpack (4.1.7)
42
+ actionview (= 4.1.7)
43
+ activesupport (= 4.1.7)
43
44
  rack (~> 1.5.2)
44
45
  rack-test (~> 0.6.2)
45
- actionview (4.1.9)
46
- activesupport (= 4.1.9)
46
+ actionview (4.1.7)
47
+ activesupport (= 4.1.7)
47
48
  builder (~> 3.1)
48
49
  erubis (~> 2.7.0)
49
50
  active_model_serializers (0.8.3)
50
51
  activemodel (>= 3.0)
51
- activemodel (4.1.9)
52
- activesupport (= 4.1.9)
52
+ activemodel (4.1.7)
53
+ activesupport (= 4.1.7)
53
54
  builder (~> 3.1)
54
- activerecord (4.1.9)
55
- activemodel (= 4.1.9)
56
- activesupport (= 4.1.9)
55
+ activerecord (4.1.7)
56
+ activemodel (= 4.1.7)
57
+ activesupport (= 4.1.7)
57
58
  arel (~> 5.0.0)
58
- activesupport (4.1.9)
59
+ activesupport (4.1.7)
59
60
  i18n (~> 0.6, >= 0.6.9)
60
61
  json (~> 1.7, >= 1.7.7)
61
62
  minitest (~> 5.1)
@@ -70,7 +71,7 @@ GEM
70
71
  auto_html (1.6.4)
71
72
  redcarpet (~> 3.1)
72
73
  rinku (~> 1.5.0)
73
- autoprefixer-rails (5.1.5)
74
+ autoprefixer-rails (5.1.6)
74
75
  execjs
75
76
  json
76
77
  awesome_print (1.6.1)
@@ -162,6 +163,29 @@ GEM
162
163
  best_in_place (~> 3.0.0.rc1)
163
164
  postgres-copy (~> 0.8.0, >= 0.8.0)
164
165
  rails (~> 4.0)
166
+ dune-balanced (1.0.0)
167
+ balanced (~> 1.1)
168
+ draper (~> 1.3)
169
+ faraday (= 0.8.9)
170
+ faraday_middleware (= 0.9.0)
171
+ rails (~> 4.0)
172
+ dune-balanced-bankaccount (1.0.0)
173
+ dune-balanced (~> 1.0)
174
+ rails (~> 4.0)
175
+ sidekiq (~> 3.0)
176
+ slim (~> 2.0)
177
+ dune-balanced-creditcard (1.0.0)
178
+ dune-balanced (~> 1.0)
179
+ rails (~> 4.0)
180
+ slim (~> 2.0)
181
+ dune-dashboard (1.0.0)
182
+ bootstrap-sass
183
+ coffee-rails
184
+ ember-rails (~> 0.15)
185
+ emblem-rails (~> 0.2)
186
+ font-awesome-sass (~> 4.2)
187
+ rails (~> 4.0)
188
+ sass-rails
165
189
  ember-data-source (1.0.0.beta.15)
166
190
  ember-source (~> 1.8)
167
191
  ember-rails (0.16.1)
@@ -323,29 +347,6 @@ GEM
323
347
  multi_json (1.10.1)
324
348
  multi_xml (0.5.5)
325
349
  multipart-post (1.2.0)
326
- neighborly-balanced (2.0.2)
327
- balanced (~> 1.1)
328
- draper (~> 1.3)
329
- faraday (= 0.8.9)
330
- faraday_middleware (= 0.9.0)
331
- rails (~> 4.0)
332
- neighborly-balanced-bankaccount (2.0.3)
333
- neighborly-balanced (~> 2.0)
334
- rails (~> 4.0)
335
- sidekiq (~> 3.0)
336
- slim (~> 2.0)
337
- neighborly-balanced-creditcard (2.0.0)
338
- neighborly-balanced (~> 2.0)
339
- rails (~> 4.0)
340
- slim (~> 2.0)
341
- neighborly-dashboard (1.0.2)
342
- bootstrap-sass
343
- coffee-rails
344
- ember-rails (~> 0.15)
345
- emblem-rails (~> 0.2)
346
- font-awesome-sass (~> 4.2)
347
- rails (~> 4.0)
348
- sass-rails
349
350
  net-scp (1.2.1)
350
351
  net-ssh (>= 2.6.5)
351
352
  net-ssh (2.9.2)
@@ -409,15 +410,15 @@ GEM
409
410
  rack
410
411
  rack-test (0.6.3)
411
412
  rack (>= 1.0)
412
- rails (4.1.9)
413
- actionmailer (= 4.1.9)
414
- actionpack (= 4.1.9)
415
- actionview (= 4.1.9)
416
- activemodel (= 4.1.9)
417
- activerecord (= 4.1.9)
418
- activesupport (= 4.1.9)
413
+ rails (4.1.7)
414
+ actionmailer (= 4.1.7)
415
+ actionpack (= 4.1.7)
416
+ actionview (= 4.1.7)
417
+ activemodel (= 4.1.7)
418
+ activerecord (= 4.1.7)
419
+ activesupport (= 4.1.7)
419
420
  bundler (>= 1.3.0, < 2.0)
420
- railties (= 4.1.9)
421
+ railties (= 4.1.7)
421
422
  sprockets-rails (~> 2.0)
422
423
  rails-observers (0.1.2)
423
424
  activemodel (~> 4.0)
@@ -426,9 +427,9 @@ GEM
426
427
  rails_stdout_logging
427
428
  rails_serve_static_assets (0.0.4)
428
429
  rails_stdout_logging (0.0.3)
429
- railties (4.1.9)
430
- actionpack (= 4.1.9)
431
- activesupport (= 4.1.9)
430
+ railties (4.1.7)
431
+ actionpack (= 4.1.7)
432
+ activesupport (= 4.1.7)
432
433
  rake (>= 0.8.7)
433
434
  thor (>= 0.18.1, < 2.0)
434
435
  raindrops (0.13.0)
@@ -503,7 +504,6 @@ GEM
503
504
  railties (>= 3.0, < 4.2)
504
505
  slim (~> 2.0)
505
506
  slop (3.6.0)
506
- spring (1.3.2)
507
507
  sprockets (2.12.3)
508
508
  hike (~> 1.2)
509
509
  multi_json (~> 1.0)
@@ -582,6 +582,10 @@ DEPENDENCIES
582
582
  dropzonejs-rails (~> 0.4.14)
583
583
  dune-admin (~> 1.2.3)
584
584
  dune-api!
585
+ dune-balanced (~> 1.0.0)
586
+ dune-balanced-bankaccount (~> 1.0.0)
587
+ dune-balanced-creditcard (~> 1.0.0)
588
+ dune-dashboard (~> 1.0.0)
585
589
  ezcrypto
586
590
  factory_girl_rails
587
591
  fakeweb
@@ -602,10 +606,6 @@ DEPENDENCIES
602
606
  launchy
603
607
  letter_opener
604
608
  minitest
605
- neighborly-balanced (~> 2.0.0)
606
- neighborly-balanced-bankaccount (~> 2.0.0)
607
- neighborly-balanced-creditcard (~> 2.0.0)
608
- neighborly-dashboard (~> 1.0.2)
609
609
  newrelic_rpm
610
610
  nprogress-rails
611
611
  omniauth
@@ -620,7 +620,7 @@ DEPENDENCIES
620
620
  pry
621
621
  pundit (~> 0.2.3)
622
622
  quiet_assets
623
- rails (= 4.1.9)
623
+ rails (= 4.1.7)
624
624
  rails-observers (~> 0.1.2)
625
625
  rails_12factor
626
626
  rake (~> 10.3)
@@ -635,7 +635,6 @@ DEPENDENCIES
635
635
  simple_form (~> 3.0.2)
636
636
  sinatra (~> 1.4.5)
637
637
  slim-rails
638
- spring
639
638
  state_machine!
640
639
  therubyracer
641
640
  thin
@@ -1,8 +1,8 @@
1
1
  FORMAT: 1A
2
2
  HOST: https://www.dune-investissement.fr/api/
3
3
 
4
- # dune-investissement
5
- Here you will find how to integrate an application with Dune. Check our [Dashboard source code](https://github.com/dune/dune-dashboard) for a real use case.
4
+ # www.dune-investissement.fr
5
+ Here you will find how to integrate an application with www.dune-investissement.fr. Check our [Dashboard source code](https://github.com/dune/dune-dashboard) for a real use case.
6
6
 
7
7
  ## Allowed HTTPs requests:
8
8
 
@@ -35,8 +35,8 @@ Here you will find how to integrate an application with Dune. Check our [Dashboa
35
35
 
36
36
  + Parameters
37
37
 
38
- + email (required, string) ... Your dune account email address
39
- + password (required, string) ... Your dune account password
38
+ + email (required, string) ... Your www.dune-investissement.fr account email address
39
+ + password (required, string) ... Your www.dune-investissement.fr account password
40
40
 
41
41
  + Request
42
42
 
@@ -597,17 +597,17 @@ Some atributes may not be saved, it will depends from the user access rights.
597
597
  + Response 403 (application/json)
598
598
 
599
599
 
600
- # Group Investments
600
+ # Group Contributions
601
601
 
602
- ## /investments
602
+ ## /contributions
603
603
 
604
- ### List investments [GET]
604
+ ### List contributions [GET]
605
605
 
606
606
  Requires the user to be an admin.
607
607
 
608
608
  + Parameters
609
609
 
610
- + query (optional, string) ... Search for investments
610
+ + query (optional, string) ... Search for contributions
611
611
  + between_values (optional, object) ... Filter between values
612
612
  + project_id (optional, string) ... Filter by project id
613
613
 
@@ -638,7 +638,7 @@ Requires the user to be an admin.
638
638
  + Response 200 (application/json)
639
639
 
640
640
  {
641
- "investments":[
641
+ "contributions":[
642
642
  {
643
643
  "id":1714,
644
644
  "project_id":62,
@@ -689,7 +689,7 @@ Requires the user to be an admin.
689
689
 
690
690
  {}
691
691
 
692
- ## /investment/{id}/confirm
692
+ ## /contribution/{id}/confirm
693
693
 
694
694
  ### Manually Confirm a Contibution [PUT]
695
695
 
@@ -713,7 +713,7 @@ Requires the user to be an admin.
713
713
 
714
714
  {}
715
715
 
716
- ## /investment/{id}/pendent
716
+ ## /contribution/{id}/pendent
717
717
 
718
718
  ### Set a Contibution as Pending [PUT]
719
719
 
@@ -737,9 +737,9 @@ Requires the user to be an admin.
737
737
 
738
738
  {}
739
739
 
740
- ## /investment/{id}/refund
740
+ ## /contribution/{id}/refund
741
741
 
742
- ### Refund an Investment [PUT]
742
+ ### Refund a Contribution [PUT]
743
743
 
744
744
  Requires the user to be an admin.
745
745
 
@@ -761,13 +761,13 @@ Requires the user to be an admin.
761
761
 
762
762
  {}
763
763
 
764
- ## /investment/{id}/hide
764
+ ## /contribution/{id}/hide
765
765
 
766
- ### Hide an Investment [PUT]
766
+ ### Hide a Contribution [PUT]
767
767
 
768
768
  Requires the user to be an admin.
769
769
 
770
- It will change the investment state to `refunded_and_canceled`.
770
+ It will change the contribution state to `refunded_and_canceled`.
771
771
 
772
772
  + Request
773
773
 
@@ -787,9 +787,9 @@ It will change the investment state to `refunded_and_canceled`.
787
787
 
788
788
  {}
789
789
 
790
- ## /investment/{id}/cancel
790
+ ## /contribution/{id}/cancel
791
791
 
792
- ### Cancel an Investment[PUT]
792
+ ### Cancel a Contribution[PUT]
793
793
 
794
794
  Requires the user to be an admin.
795
795
 
@@ -810,9 +810,9 @@ Requires the user to be an admin.
810
810
  + Response 401 (application/json)
811
811
 
812
812
 
813
- ## /investments/{id}
813
+ ## /contributions/{id}
814
814
 
815
- ### Update an Investment [PUT]
815
+ ### Update a Contribution [PUT]
816
816
 
817
817
  Requires the user to be an admin.
818
818
 
@@ -826,7 +826,7 @@ Requires the user to be an admin.
826
826
  + Body
827
827
 
828
828
  {
829
- "investment":{
829
+ "contribution":{
830
830
  "value":"10.0"
831
831
  }
832
832
  }
@@ -852,7 +852,7 @@ Requires the user to be an admin.
852
852
  }
853
853
 
854
854
 
855
- ### Fetch Investment information [GET]
855
+ ### Fetch Contribution information [GET]
856
856
 
857
857
  Requires the user to be an admin.
858
858
 
@@ -867,7 +867,7 @@ Requires the user to be an admin.
867
867
  + Response 200 (application/json)
868
868
 
869
869
  {
870
- "investment": {
870
+ "contribution": {
871
871
  "id":1714,
872
872
  "project_id":62,
873
873
  "user_id":1,
@@ -907,7 +907,7 @@ Requires the user to be an admin.
907
907
  }
908
908
  }
909
909
 
910
- ### Destroy an Investment [DELETE]
910
+ ### Destroy a Contribution [DELETE]
911
911
 
912
912
  Requires the user to be an admin.
913
913
 
@@ -1756,7 +1756,7 @@ Requires the user to be an admin.
1756
1756
  "id":277,
1757
1757
  "project_id":75,
1758
1758
  "minimum_value":"1000.0",
1759
- "maximum_investments":null,
1759
+ "maximum_contributions":null,
1760
1760
  "description":"Foo Bar Lorem",
1761
1761
  "created_at":"2014-01-09T02:36:38.297-06:00",
1762
1762
  "updated_at":"2014-01-10T18:44:53.686-06:00",
@@ -1,6 +1,6 @@
1
1
  module Dune::Api
2
2
  module V1
3
- class InvestmentsController < BaseController
3
+ class ContributionsController < BaseController
4
4
  include PaginatedController
5
5
 
6
6
  before_action :require_admin!
@@ -8,37 +8,37 @@ module Dune::Api
8
8
  has_scope :pg_search, as: :query
9
9
  has_scope :by_project_id, as: :project_id
10
10
  has_scope :between_values,
11
- using: %i(initial final),
12
- type: :hash
11
+ using: %i(initial final),
12
+ type: :hash
13
13
 
14
14
  def index
15
15
  respond_with_pagination collection
16
16
  end
17
17
 
18
18
  def show
19
- respond_with Dune::Api::Investment.find(params[:id])
19
+ respond_with Dune::Api::Contribution.find(params[:id])
20
20
  end
21
21
 
22
22
  def update
23
- @investment = ::Investment.find(params[:id])
24
- authorize @investment
25
- respond_with ::Investment.update(params[:id], permitted_params)
23
+ @contribution = ::Contribution.find(params[:id])
24
+ authorize @contribution
25
+ respond_with ::Contribution.update(params[:id], permitted_params)
26
26
  end
27
27
 
28
28
  def destroy
29
- investment = ::Investment.find(params[:id])
30
- authorize investment
29
+ contribution = ::Contribution.find(params[:id])
30
+ authorize contribution
31
31
 
32
- investment.push_to_trash!
32
+ contribution.push_to_trash!
33
33
  head :no_content
34
34
  end
35
35
 
36
36
  [:confirm, :pendent, :refund, :hide, :cancel].each do |name|
37
37
  define_method name do
38
- investment = ::Investment.find(params[:id])
39
- authorize investment
38
+ contribution = ::Contribution.find(params[:id])
39
+ authorize contribution
40
40
 
41
- investment.send("#{name.to_s}!")
41
+ contribution.send("#{name.to_s}!")
42
42
  head :no_content
43
43
  end
44
44
  end
@@ -46,19 +46,19 @@ module Dune::Api
46
46
  private
47
47
 
48
48
  def permitted_params
49
- params.permit(policy(@investment || ::Investment).permitted_attributes)[:investment]
49
+ params.permit(policy(@contribution || ::Contribution).permitted_attributes)[:contribution]
50
50
  end
51
51
 
52
52
  def collection
53
53
  @collection ||= begin
54
54
  apply_scopes(
55
- scoped_by_state(Dune::Api::Investment)
55
+ scoped_by_state(Dune::Api::Contribution)
56
56
  ).order('created_at desc').all
57
57
  end
58
58
  end
59
59
 
60
60
  def scoped_by_state(scope)
61
- state_scopes = params.slice(*Investment.state_names).keys
61
+ state_scopes = params.slice(*Contribution.state_names).keys
62
62
  if state_scopes.any?
63
63
  scope.with_state(state_scopes)
64
64
  else
@@ -1,5 +1,5 @@
1
1
  module Dune::Api
2
- class Investment < ::Investment
2
+ class Contribution < ::Contribution
3
3
  scope :between_values, ->(start_at, ends_at) do
4
4
  return all unless start_at.present? && ends_at.present?
5
5
  where('value between ? and ?',
@@ -1,5 +1,5 @@
1
1
  module Dune::Api
2
- class InvestmentSerializer < ActiveModel::Serializer
2
+ class ContributionSerializer < ActiveModel::Serializer
3
3
  def rights
4
4
  {
5
5
  can_pendent: object.can_pendent?,
@@ -2,7 +2,7 @@ class RewardSerializer < ActiveModel::Serializer
2
2
  attributes :id,
3
3
  :project_id,
4
4
  :minimum_value,
5
- :maximum_investments,
5
+ :maximum_contributions,
6
6
  :description,
7
7
  :created_at,
8
8
  :updated_at,
@@ -12,7 +12,7 @@ Dune::Api::Engine.routes.draw do
12
12
  end
13
13
  end
14
14
 
15
- resources :investments, only: %i(index show update destroy) do
15
+ resources :contributions, only: %i(index show update destroy) do
16
16
  member do
17
17
  put :confirm
18
18
  put :pendent
@@ -1,5 +1,5 @@
1
1
  module Dune
2
2
  module Api
3
- VERSION = '1.0.2'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Dune::Api::V1::InvestmentsController do
3
+ describe Dune::Api::V1::ContributionsController do
4
4
  routes { Dune::Api::Engine.routes }
5
- let!(:investment) { FactoryGirl.create(:investment) }
5
+ let!(:contribution) { FactoryGirl.create(:contribution) }
6
6
 
7
- let(:investments_returned) do
8
- parsed_response.fetch('investments').map { |t| t['id'] }
7
+ let(:contributions_returned) do
8
+ parsed_response.fetch('contributions').map { |t| t['id'] }
9
9
  end
10
10
 
11
11
  let(:parsed_response) { JSON.parse(response.body) }
@@ -16,45 +16,45 @@ describe Dune::Api::V1::InvestmentsController do
16
16
  it_behaves_like 'paginating results'
17
17
 
18
18
  it 'filters by query' do
19
- investment = FactoryGirl.create(:investment, payment_method: 'balanced')
20
- FactoryGirl.create(:investment, payment_method: 'paypal')
19
+ contribution = FactoryGirl.create(:contribution, payment_method: 'balanced')
20
+ FactoryGirl.create(:contribution, payment_method: 'paypal')
21
21
  get :index, format: :json, query: 'balanced'
22
- expect(investments_returned).to eql([investment.id])
22
+ expect(contributions_returned).to eql([contribution.id])
23
23
  end
24
24
 
25
25
  describe 'filtering by between_values' do
26
26
  before do
27
- @investment_30 = FactoryGirl.create(:investment, value: 30)
28
- @investment_35 = FactoryGirl.create(:investment, value: 35)
29
- FactoryGirl.create(:investment, value: 40)
27
+ @contribution_30 = FactoryGirl.create(:contribution, value: 30)
28
+ @contribution_35 = FactoryGirl.create(:contribution, value: 35)
29
+ FactoryGirl.create(:contribution, value: 40)
30
30
  end
31
31
 
32
- it 'returns just those investments in the given range' do
32
+ it 'returns just those contributions in the given range' do
33
33
  get :index, format: :json,
34
- between_values: {
35
- initial: 30,
36
- final: 35
37
- }
38
- expect(investments_returned).to eql([@investment_35.id, @investment_30.id])
34
+ between_values: {
35
+ initial: 30,
36
+ final: 35
37
+ }
38
+ expect(contributions_returned).to eql([@contribution_35.id, @contribution_30.id])
39
39
  end
40
40
  end
41
41
 
42
42
  describe 'filter by state' do
43
- let!(:pending_investment) do
44
- FactoryGirl.create(:investment, state: :pending)
43
+ let!(:pending_contribution) do
44
+ FactoryGirl.create(:contribution, state: :pending)
45
45
  end
46
46
 
47
- Investment.state_names.each do |state|
47
+ Contribution.state_names.each do |state|
48
48
  it "filters by state #{state}" do
49
- investment = FactoryGirl.create(:investment, state: state)
49
+ contribution = FactoryGirl.create(:contribution, state: state)
50
50
  expected_ids = if state.eql?(:pending)
51
- [investment.id, pending_investment.id]
52
- else
53
- [investment.id]
54
- end
51
+ [contribution.id, pending_contribution.id]
52
+ else
53
+ [contribution.id]
54
+ end
55
55
 
56
56
  get :index, format: :json, state => '1'
57
- expect(investments_returned).to include(*expected_ids)
57
+ expect(contributions_returned).to include(*expected_ids)
58
58
  end
59
59
  end
60
60
  end
@@ -64,34 +64,34 @@ describe Dune::Api::V1::InvestmentsController do
64
64
  let(:second_project) { FactoryGirl.create(:project, state: 'online') }
65
65
 
66
66
  before do
67
- @investment = FactoryGirl.create(:investment, value: 10, project: first_project)
68
- FactoryGirl.create(:investment, value: 10, project: second_project)
67
+ @contribution = FactoryGirl.create(:contribution, value: 10, project: first_project)
68
+ FactoryGirl.create(:contribution, value: 10, project: second_project)
69
69
  end
70
70
 
71
- it 'returns just those investments in the given project id' do
71
+ it 'returns just those contributions in the given project id' do
72
72
  get :index, project_id: first_project.id, format: :json
73
- expect(investments_returned).to eql([@investment.id])
73
+ expect(contributions_returned).to eql([@contribution.id])
74
74
  end
75
75
  end
76
76
  end
77
77
 
78
78
  describe '#show', authorized: true, admin: true do
79
- let(:do_request) { get :show, id: investment.id, format: :json }
79
+ let(:do_request) { get :show, id: contribution.id, format: :json }
80
80
 
81
81
  it 'responds with 200' do
82
82
  do_request
83
83
  expect(response.status).to eql(200)
84
84
  end
85
85
 
86
- it 'has a top level element called investment' do
86
+ it 'has a top level element called contribution' do
87
87
  do_request
88
- expect(parsed_response.fetch('investment')).to be_a(Hash)
88
+ expect(parsed_response.fetch('contribution')).to be_a(Hash)
89
89
  end
90
90
 
91
- it 'responds with data of the given investment' do
91
+ it 'responds with data of the given contribution' do
92
92
  do_request
93
93
  expect(
94
- parsed_response.fetch('investment')
94
+ parsed_response.fetch('contribution')
95
95
  ).to have_key('id')
96
96
  end
97
97
  end
@@ -99,14 +99,14 @@ describe Dune::Api::V1::InvestmentsController do
99
99
  describe '#update', authorized: true, admin: true do
100
100
  let(:do_request) do
101
101
  put :update,
102
- id: investment.id,
103
- investment: { value: 15 },
102
+ id: contribution.id,
103
+ contribution: { value: 15 },
104
104
  format: :json
105
105
  end
106
106
 
107
107
  it 'updates the record' do
108
- expect(::Investment).to receive(:update)
109
- .with(investment.id.to_s, { 'value' => 15 })
108
+ expect(::Contribution).to receive(:update)
109
+ .with(contribution.id.to_s, { 'value' => 15 })
110
110
 
111
111
  do_request
112
112
  end
@@ -121,8 +121,8 @@ describe Dune::Api::V1::InvestmentsController do
121
121
  context 'on failure' do
122
122
  let(:do_request) do
123
123
  put :update,
124
- id: investment.id,
125
- investment: { value: nil },
124
+ id: contribution.id,
125
+ contribution: { value: nil },
126
126
  format: :json
127
127
  end
128
128
 
@@ -141,23 +141,23 @@ describe Dune::Api::V1::InvestmentsController do
141
141
  end
142
142
 
143
143
  describe 'destroy', authorized: true, admin: true do
144
- let(:do_request) { delete :destroy, id: investment.id, format: :json }
144
+ let(:do_request) { delete :destroy, id: contribution.id, format: :json }
145
145
 
146
146
  it 'returns a success http status' do
147
147
  do_request
148
148
  expect(response.status).to eq(204)
149
- expect(investment.reload.deleted?).to be_truthy
149
+ expect(contribution.reload.deleted?).to be_truthy
150
150
  end
151
151
  end
152
152
 
153
153
  [:confirm, :pendent, :refund, :hide, :cancel].each do |name|
154
154
  describe "#{name}", authorized: true, admin: true do
155
155
  let(:user) { FactoryGirl.create(:user, admin: true) }
156
- let(:investment) do
156
+ let(:contribution) do
157
157
  state = (name == :refund) ? 'confirmed' : 'deleted'
158
- FactoryGirl.create(:investment, state: state)
158
+ FactoryGirl.create(:contribution, state: state)
159
159
  end
160
- let(:do_request) { put name, id: investment.id, format: :json }
160
+ let(:do_request) { put name, id: contribution.id, format: :json }
161
161
 
162
162
  it 'returns a success http status' do
163
163
  do_request
@@ -165,12 +165,12 @@ describe Dune::Api::V1::InvestmentsController do
165
165
  end
166
166
 
167
167
  it 'authorizes the resource' do
168
- expect(controller).to receive(:authorize).with(investment)
168
+ expect(controller).to receive(:authorize).with(contribution)
169
169
  do_request
170
170
  end
171
171
 
172
172
  it 'calls the state machine helper to change the state' do
173
- expect_any_instance_of(Investment).to receive("#{name}!")
173
+ expect_any_instance_of(Contribution).to receive("#{name}!")
174
174
  do_request
175
175
  end
176
176
  end
@@ -18,7 +18,7 @@ FactoryGirl.define do
18
18
  category
19
19
  end
20
20
 
21
- factory :investment do
21
+ factory :contribution do
22
22
  project { create(:project, state: 'online') }
23
23
  user
24
24
  confirmed_at Time.now
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Dune::Api::Investment do
3
+ describe Dune::Api::Contribution do
4
4
  describe '.between_values' do
5
- it 'returns the investments with value between 15 and 20' do
6
- FactoryGirl.create(:investment, value: 10)
7
- FactoryGirl.create(:investment, value: 15)
8
- FactoryGirl.create(:investment, value: 20)
9
- FactoryGirl.create(:investment, value: 21)
5
+ it 'returns the contributions with value between 15 and 20' do
6
+ FactoryGirl.create(:contribution, value: 10)
7
+ FactoryGirl.create(:contribution, value: 15)
8
+ FactoryGirl.create(:contribution, value: 20)
9
+ FactoryGirl.create(:contribution, value: 21)
10
10
 
11
11
  expect(described_class.between_values(15, 20).size).to eq 2
12
12
  end
@@ -22,11 +22,11 @@ describe Dune::Api::Investment do
22
22
  let(:second_project) { FactoryGirl.create(:project, state: 'online') }
23
23
 
24
24
  before do
25
- FactoryGirl.create(:investment, value: 10, project: first_project)
26
- FactoryGirl.create(:investment, value: 10, project: second_project)
25
+ FactoryGirl.create(:contribution, value: 10, project: first_project)
26
+ FactoryGirl.create(:contribution, value: 10, project: second_project)
27
27
  end
28
28
 
29
- it 'returns the investments from the first project' do
29
+ it 'returns the contributions from the first project' do
30
30
  expect(described_class.by_project_id(first_project.id).size).to eq 1
31
31
  end
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dune-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Legrand
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-17 00:00:00.000000000 Z
11
+ date: 2015-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: has_scope
@@ -132,7 +132,7 @@ files:
132
132
  - app/controllers/dune/api/base_controller.rb
133
133
  - app/controllers/dune/api/v1/channels/members_controller.rb
134
134
  - app/controllers/dune/api/v1/channels_controller.rb
135
- - app/controllers/dune/api/v1/investments_controller.rb
135
+ - app/controllers/dune/api/v1/contributions_controller.rb
136
136
  - app/controllers/dune/api/v1/press_assets_controller.rb
137
137
  - app/controllers/dune/api/v1/projects_controller.rb
138
138
  - app/controllers/dune/api/v1/rewards_controller.rb
@@ -140,12 +140,12 @@ files:
140
140
  - app/controllers/dune/api/v1/tags_controller.rb
141
141
  - app/controllers/dune/api/v1/users_controller.rb
142
142
  - app/models/dune/api/access_token.rb
143
- - app/models/dune/api/investment.rb
143
+ - app/models/dune/api/contribution.rb
144
144
  - app/models/dune/api/project.rb
145
145
  - app/models/dune/api/user_concern.rb
146
146
  - app/serializers/channel_member_serializer.rb
147
147
  - app/serializers/channel_serializer.rb
148
- - app/serializers/dune/api/investment_serializer.rb
148
+ - app/serializers/dune/api/contribution_serializer.rb
149
149
  - app/serializers/dune/api/project_serializer.rb
150
150
  - app/serializers/press_asset_serializer.rb
151
151
  - app/serializers/reward_serializer.rb
@@ -163,7 +163,7 @@ files:
163
163
  - spec/constraints/dune/api/api_constraint_spec.rb
164
164
  - spec/controllers/dune/api/v1/channels/members_controller_spec.rb
165
165
  - spec/controllers/dune/api/v1/channels_controller_spec.rb
166
- - spec/controllers/dune/api/v1/investments_controller_spec.rb
166
+ - spec/controllers/dune/api/v1/contributions_controller_spec.rb
167
167
  - spec/controllers/dune/api/v1/press_assets_controller_spec.rb
168
168
  - spec/controllers/dune/api/v1/projects_controller_spec.rb
169
169
  - spec/controllers/dune/api/v1/rewards_controller_spec.rb
@@ -172,7 +172,7 @@ files:
172
172
  - spec/controllers/dune/api/v1/users_controller_spec.rb
173
173
  - spec/factories.rb
174
174
  - spec/fixtures/image.png
175
- - spec/models/dune/api/investment_spec.rb
175
+ - spec/models/dune/api/contribution_spec.rb
176
176
  - spec/models/dune/api/user_concern_spec.rb
177
177
  - spec/spec_helper.rb
178
178
  - spec/support/shared_examples.rb
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  version: '0'
197
197
  requirements: []
198
198
  rubyforge_project:
199
- rubygems_version: 2.4.3
199
+ rubygems_version: 2.2.2
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: dune API
@@ -204,7 +204,7 @@ test_files:
204
204
  - spec/constraints/dune/api/api_constraint_spec.rb
205
205
  - spec/controllers/dune/api/v1/channels/members_controller_spec.rb
206
206
  - spec/controllers/dune/api/v1/channels_controller_spec.rb
207
- - spec/controllers/dune/api/v1/investments_controller_spec.rb
207
+ - spec/controllers/dune/api/v1/contributions_controller_spec.rb
208
208
  - spec/controllers/dune/api/v1/press_assets_controller_spec.rb
209
209
  - spec/controllers/dune/api/v1/projects_controller_spec.rb
210
210
  - spec/controllers/dune/api/v1/rewards_controller_spec.rb
@@ -213,7 +213,7 @@ test_files:
213
213
  - spec/controllers/dune/api/v1/users_controller_spec.rb
214
214
  - spec/factories.rb
215
215
  - spec/fixtures/image.png
216
- - spec/models/dune/api/investment_spec.rb
216
+ - spec/models/dune/api/contribution_spec.rb
217
217
  - spec/models/dune/api/user_concern_spec.rb
218
218
  - spec/spec_helper.rb
219
219
  - spec/support/shared_examples.rb