update view tests

This commit is contained in:
Jorge Morante
2019-03-21 15:47:06 +01:00
parent 265961c728
commit 9aa2b48218
2 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,37 @@
require 'spec_helper'
RSpec.describe 'inquiries/show' do
let(:organization) { Fabricate(:organization) }
let(:member) { Fabricate(:member, organization: organization) }
let(:inquiry) { Fabricate(:inquiry, user: member.user, organization: organization) }
let(:group_inquiry) { Fabricate(:inquiry, user: member.user, organization: organization, is_group: true) }
let(:destination_account) { Fabricate(:account) }
context 'when the user is not logged in' do
before do
allow(view).to receive(:current_user).and_return(nil)
allow(view).to receive(:current_organization).and_return(nil)
end
context 'when it is not a group inquiry' do
it 'displays a label' do
assign :inquiry, inquiry
assign :destination_account, destination_account
render template: 'inquiries/show'
expect(rendered).to_not include(I18n.t('activerecord.attributes.inquiry.is_group'))
end
end
context 'when it is a group inquiry' do
it 'displays a label' do
assign :inquiry, group_inquiry
assign :destination_account, destination_account
render template: 'inquiries/show'
expect(rendered).to include(I18n.t('activerecord.attributes.inquiry.is_group'))
end
end
end
end

View File

@ -4,6 +4,7 @@ RSpec.describe 'offers/show' do
let(:organization) { Fabricate(:organization) }
let(:member) { Fabricate(:member, organization: organization) }
let(:offer) { Fabricate(:offer, user: member.user, organization: organization) }
let(:group_offer) { Fabricate(:offer, user: member.user, organization: organization, is_group: true) }
let(:destination_account) { Fabricate(:account) }
before do
@ -152,5 +153,25 @@ RSpec.describe 'offers/show' do
expect(rendered).to_not include(offer.user.email)
end
context 'when it is not a group offer' do
it 'displays a label' do
assign :offer, offer
assign :destination_account, destination_account
render template: 'offers/show'
expect(rendered).to_not include(I18n.t('activerecord.attributes.offer.is_group'))
end
end
context 'when it is a group offer' do
it 'displays a label' do
assign :offer, group_offer
assign :destination_account, destination_account
render template: 'offers/show'
expect(rendered).to include(I18n.t('activerecord.attributes.offer.is_group'))
end
end
end
end