adaptation of specs
This commit is contained in:
parent
0a5170f8cc
commit
0075b508a3
2 changed files with 193 additions and 14 deletions
|
@ -19,7 +19,7 @@ describe 'shared/attachment/_update.html.haml', type: :view do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when there is a attached file' do
|
||||
context 'when there is an attached file' do
|
||||
it 'renders a form field for uploading a file' do
|
||||
expect(subject).to have_selector('input[type=file]:not(.hidden)')
|
||||
end
|
||||
|
@ -28,7 +28,7 @@ describe 'shared/attachment/_update.html.haml', type: :view do
|
|||
expect(subject).not_to have_content(attached_file.filename.to_s)
|
||||
end
|
||||
|
||||
it 'doesn’t render action buttons' do
|
||||
it 'does not render action buttons' do
|
||||
expect(subject).not_to have_link('Remplacer')
|
||||
expect(subject).not_to have_link('Supprimer')
|
||||
end
|
||||
|
@ -40,23 +40,30 @@ describe 'shared/attachment/_update.html.haml', type: :view do
|
|||
expect(subject).to have_content(attached_file.filename.to_s)
|
||||
end
|
||||
|
||||
it 'renders action buttons' do
|
||||
expect(subject).to have_button('Remplacer')
|
||||
end
|
||||
|
||||
it 'hides the form field by default' do
|
||||
expect(subject).to have_selector('input[type=file].hidden')
|
||||
end
|
||||
|
||||
it 'hides the Delete button by default' do
|
||||
is_expected.not_to have_link('Supprimer')
|
||||
end
|
||||
|
||||
context 'and the user can delete the attachment' do
|
||||
let(:user_can_destroy) { true }
|
||||
|
||||
it { is_expected.to have_link('Supprimer') }
|
||||
it 'shows the Delete button by default' do
|
||||
is_expected.to have_link('Supprimer')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the user cannot destroy the attachment' do
|
||||
subject do
|
||||
form_for(champ.dossier) do |form|
|
||||
render 'shared/attachment/edit', {
|
||||
form: form,
|
||||
attached_file: attached_file,
|
||||
accept: 'image/png',
|
||||
user_can_destroy: user_can_destroy
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
it 'hides the Delete button' do
|
||||
is_expected.not_to have_link('Supprimer')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue