Skip to content

Commit

Permalink
add some organizations#show view specs
Browse files Browse the repository at this point in the history
  • Loading branch information
markets committed May 28, 2018
1 parent 5eb672e commit 2f65ae0
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 4 deletions.
16 changes: 12 additions & 4 deletions spec/controllers/organizations_controller_spec.rb
Expand Up @@ -6,13 +6,21 @@

describe 'GET #show' do
context 'with a logged user (organization member)' do
it 'links to new_transfer_path' do
it 'displays the organization page' do
login(member.user)

get 'show', id: organization.id
expect(response.body).to include(
"<a href=\"/transfers/new?destination_account_id=#{organization.account.id}&amp;id=#{organization.id}\">"
)

expect(response.body).to include(organization.name)
end
end

context 'without a logged user' do
it 'redirects to the root path' do
get 'show', id: organization.id

expect(response).to redirect_to(root_path)
expect(flash[:error]).to eq('You are not authorized to perform this action.')
end
end
end
Expand Down
60 changes: 60 additions & 0 deletions spec/views/organizations/show.html.erb_spec.rb
@@ -0,0 +1,60 @@
require 'spec_helper'

RSpec.describe 'offers/show' do
let(:organization) { Fabricate(:organization) }

before do
allow(view).to receive(:admin?).and_return(false)
allow(view).to receive(:superadmin?).and_return(false)

assign :organization, organization
end

context 'without a logged user' do
before do
allow(view).to receive(:current_user).and_return(nil)

assign :movements, []
render template: 'organizations/show'
end

it 'links to new_transfer_path' do
expect(rendered).to have_link(
t('global.give_time'),
href: new_transfer_path(
id: organization,
destination_account_id: organization.account.id
)
)
end

it 'does not diplay the movements section' do
expect(rendered).not_to match t('organizations.movements')
end
end

context 'with a logged user' do
let(:user) { Fabricate(:user) }

before do
allow(view).to receive(:current_user).and_return(user)

assign :movements, Movement.page
render template: 'organizations/show'
end

it 'links to new_transfer_path' do
expect(rendered).to have_link(
t('global.give_time'),
href: new_transfer_path(
id: organization,
destination_account_id: organization.account.id
)
)
end

it 'diplays the movements' do
expect(rendered).to match t('shared.movements.movements')
end
end
end

0 comments on commit 2f65ae0

Please sign in to comment.