Commit a9dd14ea80280dff7036a4930dfbd042cee36372
1 parent
50c4dc64
Exists in
colab
and in
2 other branches
Create latest Repositories listing method
This is a information that will get published at the homepage.
Showing
2 changed files
with
28 additions
and
0 deletions
Show diff stats
app/models/repository.rb
| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | +require 'rails_helper' | |
| 2 | + | |
| 3 | +describe Repository do | |
| 4 | + describe 'class method' do | |
| 5 | + describe 'latest' do | |
| 6 | + let!(:repository) { FactoryGirl.build(:repository, id: 1) } | |
| 7 | + let!(:another_repository) { FactoryGirl.build(:another_repository, id: 2) } | |
| 8 | + | |
| 9 | + before do | |
| 10 | + Repository.expects(:all).returns([repository, another_repository]) | |
| 11 | + end | |
| 12 | + | |
| 13 | + it 'should return the two repositorys ordered' do | |
| 14 | + expect(Repository.latest(2)).to eq([another_repository, repository]) | |
| 15 | + end | |
| 16 | + | |
| 17 | + context 'when no parameter is passed' do | |
| 18 | + it 'should return just the most recent repository' do | |
| 19 | + expect(Repository.latest).to eq([another_repository]) | |
| 20 | + end | |
| 21 | + end | |
| 22 | + end | |
| 23 | + end | |
| 24 | +end | |
| 0 | 25 | \ No newline at end of file | ... | ... |