fix specs fpr seeds rss feed

This commit is contained in:
Brenda Wallace
2019-12-25 11:42:29 +13:00
parent 2c5d5e0983
commit 5962081c9e
2 changed files with 33 additions and 20 deletions

View File

@@ -10,12 +10,13 @@
%pubdate= seed['created_at'].to_s(:rfc822)
%description
:escaped
SEED: #{seed}
<p>Quantity: #{seed['quantity'] ? seed['quantity'] : 'unknown' }</p>
<p>Plant before: #{seed['plant_before'] ? seed['plant_before'] : 'unknown' }</p>
<p>Organic? #{seed['organic']}</p>
<p>GMO? #{seed['gmo']}</p>
<p>Heirloom? #{seed['heirloom']}</p>
<p>Will trade #{seed['tradable_to']} from #{seed['location'] ? seed['location'] : 'unknown location'}</p>
- if seed['tradeable']
:escaped
<p>Will trade #{seed['tradable_to']} from #{seed['location'] ? seed['location'] : 'unknown location'}</p>
%link= seed_url(slug: seed['slug'])
%guid= seed_url(slug: seed['slug'])

View File

@@ -7,21 +7,9 @@ describe 'seeds/index.rss.haml', :search do
controller.stub(:current_user) { nil }
end
context 'all seeds' do
let(:seed) { FactoryBot.create(:seed) }
before do
@tradable = FactoryBot.create(:tradable_seed)
Seed.searchkick_index.refresh
assign(:seeds, Seed.search(load: false))
render
end
it 'shows RSS feed title' do
expect(rendered).to have_content "Recent seeds from all members"
end
shared_examples 'displays seed in rss feed' do
it 'has a useful item title' do
expect(rendered).to have_content "#{seed.owner.login_name}'s #{seed.crop} seeds"
expect(rendered).to have_content "#{seed.owner.login_name}'s #{seed.crop.name} seeds"
end
it 'shows the seed count' do
@@ -31,23 +19,47 @@ describe 'seeds/index.rss.haml', :search do
it 'shows the plant_before date' do
expect(rendered).to have_content "Plant before: #{seed.plant_before.to_s(:ymd)}"
end
end
context 'all seeds' do
let!(:seed) { FactoryBot.create(:seed) }
let!(:tradable) { FactoryBot.create(:tradable_seed) }
before do
Seed.searchkick_index.refresh
assign(:seeds, Seed.search(load: false))
render
end
include_examples 'displays seed in rss feed'
it 'shows RSS feed title' do
expect(rendered).to have_content "Recent seeds from all members"
end
it 'mentions that one seed is tradable' do
expect(rendered).to have_content "Will trade #{@tradable.tradable_to} from #{@tradable.owner.location}"
expect(rendered).to have_content "Will trade #{tradable.tradable_to} from #{tradable.owner.location}"
end
it "does not offer untradable seed as tradeable" do
expect(rendered).not_to have_content "Will trade #{seed.tradable_to} from #{seed.owner.location}"
end
end
context "one member's seeds" do
let!(:seed) { FactoryBot.create(:seed) }
before do
seed = FactoryBot.create(:seed)
assign(:seeds, [seed])
assign(:owner, seed.owner)
Seed.reindex
Seed.searchkick_index.refresh
assign(:seeds, Seed.search(load: false))
render
end
it 'shows RSS feed title' do
expect(rendered).to have_content "Recent seeds from #{seed.owner}"
end
include_examples 'displays seed in rss feed'
end
end