Sha256: 8ad9d954e7bea91d7840f0e472d00cf75b903bc211b3a28b60c6daec89ff9951

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe Dune::Api::Contribution do
  describe '.between_values' do
    it 'returns the contributions with value between 15 and 20' do
      FactoryGirl.create(:contribution, value: 10)
      FactoryGirl.create(:contribution, value: 15)
      FactoryGirl.create(:contribution, value: 20)
      FactoryGirl.create(:contribution, value: 21)

      expect(described_class.between_values(15, 20).size).to eq 2
    end

    it 'removes comma and transform it to float' do
      expect(described_class).to receive(:where).with('value between ? and ?', 1000.0, 2000.4)
      described_class.between_values('1,000', '2,000.40')
    end
  end

  describe '.by_project_id' do
    let(:first_project)  { FactoryGirl.create(:project, state: 'online') }
    let(:second_project) { FactoryGirl.create(:project, state: 'online') }

    before do
      FactoryGirl.create(:contribution, value: 10, project: first_project)
      FactoryGirl.create(:contribution, value: 10, project: second_project)
    end

    it 'returns the contributions from the first project' do
      expect(described_class.by_project_id(first_project.id).size).to eq 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dune-api-1.1.0 spec/models/dune/api/contribution_spec.rb