Skip to content

Commit

Permalink
Merge pull request #6493 from eduardoj/add_cassettes_to_attributes_tests
Browse files Browse the repository at this point in the history
Fix Bootstrap feature attributes tests
  • Loading branch information
bgeuken committed Dec 7, 2018
2 parents e823f19 + 110e810 commit bdb27af
Show file tree
Hide file tree
Showing 4 changed files with 541 additions and 34 deletions.
77 changes: 43 additions & 34 deletions src/api/spec/bootstrap/features/webui/attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,62 @@
RSpec.feature 'Bootstrap_Attributes', type: :feature, js: true do
let!(:user) { create(:confirmed_user) }
let!(:attribute_type) { create(:attrib_type, name: 'MyImageTemplates') }
let!(:attribute) { create(:attrib, project: user.home_project) }
let(:attribute) { create(:attrib, project: user.home_project) }

context 'for a project' do
context 'without permissions' do
let!(:other_user) { create(:confirmed_user) }
context 'with an attribute' do
before do
# create attrib as user
User.current = user
attribute
User.current = nil
end

context 'for a project' do
context 'without permissions' do
let!(:other_user) { create(:confirmed_user) }

scenario 'it is not possible to add an attribute, the link is not shown' do
login other_user
scenario 'it is not possible to add an attribute, the link is not shown' do
login other_user

visit index_attribs_path(project: user.home_project_name)
expect(page).not_to have_content('Add a new attribute')
visit index_attribs_path(project: user.home_project_name)
expect(page).not_to have_content('Add a new attribute')
end
end
end

context 'with permissions' do
scenario 'remove attribute' do
login user
context 'with permissions' do
scenario 'remove attribute' do
login user

visit index_attribs_path(project: user.home_project_name)
click_link 'Delete attribute'
expect(find("#delete-attribute-modal-#{attribute.id}")).to have_text('Delete attribute?')
within("#delete-attribute-modal-#{attribute.id} .modal-footer") do
expect(page).to have_button('Delete')
click_button('Delete')
end
expect(page).to have_css('#flash')
within('#flash') do
expect(page).to have_text('Attribute sucessfully deleted!')
visit index_attribs_path(project: user.home_project_name)
click_link 'Delete attribute'
expect(find("#delete-attribute-modal-#{attribute.id}")).to have_text('Delete attribute?')
within("#delete-attribute-modal-#{attribute.id} .modal-footer") do
expect(page).to have_button('Delete')
click_button('Delete')
end
expect(page).to have_css('#flash')
within('#flash') do
expect(page).to have_text('Attribute sucessfully deleted!')
end
end
end
end
end

context 'for a project with a package' do
let!(:package) do
create(:package, project: user.home_project)
end
context 'for a project with a package' do
let!(:package) do
create(:package, project: user.home_project)
end

scenario 'add attribute with values' do
login user
scenario 'add attribute with values' do
login user

add_attribute_with_values(package)
expect(page).to have_content('Attribute was successfully updated.')
add_attribute_with_values(package)
expect(page).to have_content('Attribute was successfully updated.')

visit index_attribs_path(project: user.home_project_name, package: package.name)
attribute_type_value = page.all('#attributes tr td', exact_text: attribute_type.fullname)[0].sibling('td', match: :first).text
expect(attribute_type_value).to eq("test\n2nd line\ntest 1")
visit index_attribs_path(project: user.home_project_name, package: package.name)
attribute_type_value = page.all('#attributes tr td', exact_text: attribute_type.fullname)[0].sibling('td', match: :first).text
expect(attribute_type_value).to eq("test\n2nd line\ntest 1")
end
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bdb27af

Please sign in to comment.