-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6379 from saraycp/project_attributes
Project attributes on bootstrap
- Loading branch information
Showing
10 changed files
with
102 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'browser_helper' | ||
|
||
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) } | ||
|
||
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 | ||
|
||
visit index_attribs_path(project: user.home_project_name) | ||
expect(page).not_to have_content('Add a new attribute') | ||
end | ||
end | ||
|
||
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!') | ||
end | ||
end | ||
end | ||
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 | ||
|
||
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") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module FeaturesAttribute | ||
def add_attribute_with_values(package = nil) | ||
visit index_attribs_path(project: user.home_project_name, package: package.try(:name)) | ||
click_link('Add a new attribute') | ||
expect(page).to have_text('Add Attribute') | ||
find('select#attrib_attrib_type_id').select("#{attribute_type.attrib_namespace}:#{attribute_type.name}") | ||
click_button('Add') | ||
expect(page).to have_content('Attribute was successfully created.') | ||
|
||
# FIXME: With the cocoon gem, the first click is somehow not registered... but only when testing in Capybara | ||
click_link('Add a value') | ||
fill_in 'Value', with: 'test 1', match: :first | ||
|
||
click_link('Add a value') | ||
# Workaround to enter data into second textfield | ||
within('div.nested-fields:nth-of-type(2)') do | ||
fill_in 'Value', with: "test\n2nd line" | ||
end | ||
|
||
click_button('Save') | ||
end | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.include FeaturesAttribute, type: :feature | ||
end |