Merge branch 'master' into aperez-dates-for-milestones

This commit is contained in:
BertoCQ
2017-12-14 15:42:35 +01:00
committed by GitHub
49 changed files with 380 additions and 395 deletions

View File

@@ -19,7 +19,8 @@ describe InstallationController, type: :request do
'user.recommendations' => nil,
'community' => nil,
'map' => 't',
'spending_proposal_features.voting_allowed' => 't'
'spending_proposal_features.voting_allowed' => 't',
'allow_images' => 't'
}
end
@@ -42,6 +43,7 @@ describe InstallationController, type: :request do
Setting['feature.community'] = true
Setting['feature.map'] = nil
Setting['feature.spending_proposal_features.voting_allowed'] = nil
Setting['feature.allow_images'] = true
end
specify "with query string inside query params" do

View File

@@ -9,6 +9,14 @@ feature 'Budget Investments' do
let(:group) { create(:budget_group, name: "Health", budget: budget) }
let!(:heading) { create(:budget_heading, name: "More hospitals", group: group) }
before do
Setting['feature.allow_images'] = true
end
after do
Setting['feature.allow_images'] = nil
end
scenario 'Index' do
investments = [create(:budget_investment, heading: heading),
create(:budget_investment, heading: heading),
@@ -37,7 +45,7 @@ feature 'Budget Investments' do
visit budget_investments_path(budget, heading_id: heading.id)
within("#budget_investment_#{investment.id}") do
expect(page).to have_css("div.no-image")
expect(page).to_not have_css("div.with-image")
end
within("#budget_investment_#{investment_with_image.id}") do
expect(page).to have_css("img[alt='#{investment_with_image.image.title}']")

View File

@@ -24,16 +24,6 @@ feature 'Communities' do
expect(page).to have_content proposal.title
expect(page).to have_content "Participate in the community of this proposal"
expect(page).to have_link("Create topic", href: new_community_topic_path(community))
expect(page).not_to have_selector(".button.disabled", text: "Create topic")
end
scenario 'Should display disabled create topic button when user is not logged' do
proposal = create(:proposal)
community = proposal.community
visit community_path(community)
expect(page).to have_selector(".button.disabled", text: "Create topic")
end
scenario 'Should display without_topics_text and participants when there are not topics' do
@@ -100,7 +90,7 @@ feature 'Communities' do
expect(topic2.title).to appear_before(topic1.title)
end
scenario 'Should display topic edit button when author is logged' do
scenario 'Should display topic edit button on topic show when author is logged' do
proposal = create(:proposal)
community = proposal.community
user = create(:user)
@@ -108,15 +98,11 @@ feature 'Communities' do
topic2 = create(:topic, community: community)
login_as(user)
visit community_path(community)
visit community_topic_path(community, topic1)
expect(page).to have_link("Edit topic", href: edit_community_topic_path(community, topic1))
within "#topic_#{topic1.id}" do
expect(page).to have_link("Edit", href: edit_community_topic_path(community, topic1))
end
within "#topic_#{topic2.id}" do
expect(page).not_to have_link("Edit", href: edit_community_topic_path(community, topic2))
end
visit community_topic_path(community, topic2)
expect(page).not_to have_link("Edit topic", href: edit_community_topic_path(community, topic2))
end
scenario 'Should display participant when there is topics' do

View File

@@ -10,6 +10,15 @@ feature 'Proposals' do
end
context 'Index' do
before do
Setting['feature.allow_images'] = true
end
after do
Setting['feature.allow_images'] = nil
end
scenario 'Lists featured and regular proposals' do
featured_proposals = create_featured_proposals
proposals = [create(:proposal), create(:proposal), create(:proposal)]
@@ -61,7 +70,7 @@ feature 'Proposals' do
visit proposals_path(proposal)
within("#proposal_#{proposal.id}") do
expect(page).to have_css("div.no-image")
expect(page).to_not have_css("div.with-image")
end
within("#proposal_#{proposal_with_image.id}") do
expect(page).to have_css("img[alt='#{proposal_with_image.image.title}']")

View File

@@ -4,13 +4,16 @@ feature 'Topics' do
context 'New' do
scenario 'Should display disabled button to new topic page without user logged', :js do
scenario 'Create new topic link should redirect to sign up for anonymous users', :js do
proposal = create(:proposal)
community = proposal.community
logout
visit community_path(community)
click_link "Create topic"
expect(page).to have_selector(".button.expanded.disabled")
expect(page).to have_content "Sign in with:"
expect(current_path).to eq(new_user_session_path)
end
scenario 'Can access to new topic page with user logged', :js do
@@ -34,8 +37,8 @@ feature 'Topics' do
click_link "Create topic"
expect(page).to have_content "Topic Title"
expect(page).to have_content "Description"
expect(page).to have_content "Title"
expect(page).to have_content "Initial text"
expect(page).to have_content "Recommendations to create a topic"
expect(page).to have_content "Do not write the topic title or whole sentences in capital letters. On the internet that is considered shouting. And no one likes to be yelled at."
expect(page).to have_content "Any topic or comment that implies an illegal action will be eliminated, also those that intend to sabotage the spaces of the subject, everything else is allowed."
@@ -128,9 +131,9 @@ feature 'Topics' do
user = create(:user)
topic = create(:topic, community: community, author: user)
login_as(user)
visit community_path(community)
visit community_topic_path(community, topic)
click_link "Destroy"
click_link "Destroy topic"
expect(page).to have_content "Topic deleted successfully."
expect(page).not_to have_content topic.title

View File

@@ -259,6 +259,9 @@ feature 'Users' do
end
scenario 'User can display public page' do
proposal = create(:proposal, tag_list: "Sport")
create(:follow, :followed_proposal, followable: proposal, user: @user)
login_as(@user)
visit account_path
@@ -267,22 +270,29 @@ feature 'Users' do
logout
visit user_path(@user)
visit user_path(@user, filter: 'follows', page: '1')
expect(page).to have_css('#public_interests')
end
scenario 'Is always visible for the owner' do
proposal = create(:proposal, tag_list: "Sport")
create(:follow, :followed_proposal, followable: proposal, user: @user)
login_as(@user)
visit account_path
uncheck 'account_public_interests'
click_button 'Save changes'
visit user_path(@user)
visit user_path(@user, filter: 'follows', page: '1')
expect(page).to have_css('#public_interests')
end
scenario 'Is always visible for admins' do
proposal = create(:proposal, tag_list: "Sport")
create(:follow, :followed_proposal, followable: proposal, user: @user)
login_as(@user)
visit account_path
@@ -292,11 +302,14 @@ feature 'Users' do
logout
login_as(create(:administrator).user)
visit user_path(@user)
visit user_path(@user, filter: 'follows', page: '1')
expect(page).to have_css('#public_interests')
end
scenario 'Is always visible for moderators' do
proposal = create(:proposal, tag_list: "Sport")
create(:follow, :followed_proposal, followable: proposal, user: @user)
login_as(@user)
visit account_path
@@ -306,38 +319,29 @@ feature 'Users' do
logout
login_as(create(:moderator).user)
visit user_path(@user)
visit user_path(@user, filter: 'follows', page: '1')
expect(page).to have_css('#public_interests')
end
scenario 'Should display generic interests title' do
@user.update(public_interests: true)
visit user_path(@user)
proposal = create(:proposal, tag_list: "Sport")
create(:follow, :followed_proposal, followable: proposal, user: @user)
expect(page).to have_content("List of interests (tags of elements this user follows)")
@user.update(public_interests: true)
visit user_path(@user, filter: 'follows', page: '1')
expect(page).to have_content("Tags of elements this user follows")
end
scenario 'Should display custom interests title when user is visiting own user page' do
proposal = create(:proposal, tag_list: "Sport")
create(:follow, :followed_proposal, followable: proposal, user: @user)
@user.update(public_interests: true)
login_as(@user)
visit user_path(@user)
visit user_path(@user, filter: 'follows', page: '1')
expect(page).to have_content("List of interests (tags of elements you follow)")
end
scenario 'Should display generic empty interests list message when visited user has not interests defined' do
@user.update(public_interests: true)
visit user_path(@user)
expect(page).to have_content("This user does not follow any elements yet.")
end
scenario 'Should display custom empty interests list message when user has not interests defined and user is visiting own user page' do
@user.update(public_interests: true)
login_as(@user)
visit user_path(@user)
expect(page).to have_content("You do not follow any elements yet.")
expect(page).to have_content("Tags of elements you follow")
end
end
@@ -418,22 +422,22 @@ feature 'Users' do
expect(page).to have_content('1 Following')
end
scenario 'Display accordion proposal tab when user is following one proposal at least' do
scenario 'Display proposal tab when user is following one proposal at least' do
proposal = create(:proposal)
create(:follow, followable: proposal, user: @user)
visit user_path(@user, filter: "follows")
expect(page).to have_link('Citizen proposals', href: "#")
expect(page).to have_link('Citizen proposals', href: "#citizen_proposals")
end
scenario 'Not display accordion proposal tab when user is not following any proposal' do
scenario 'Not display proposal tab when user is not following any proposal' do
visit user_path(@user, filter: "follows")
expect(page).not_to have_link('Citizen proposals', href: "#")
expect(page).not_to have_link('Citizen proposals', href: "#citizen_proposals")
end
scenario 'Display proposal with action buttons inside accordion proposal tab when current user is proposal author', :js do
scenario 'Display proposals with link to proposal' do
proposal = create(:proposal, author: @user)
create(:follow, followable: proposal, user: @user)
login_as @user
@@ -442,35 +446,7 @@ feature 'Users' do
click_link 'Citizen proposals'
expect(page).to have_content proposal.title
expect(page).to have_link "Send notification"
expect(page).to have_link "Retire"
end
scenario 'Display proposal with action buttons inside accordion proposal tab when there is no logged user', :js do
proposal = create(:proposal, author: @user)
create(:follow, followable: proposal, user: @user)
visit user_path(@user, filter: "follows")
click_link 'Citizen proposals'
expect(page).to have_content proposal.title
expect(page).not_to have_link "Send notification"
expect(page).not_to have_link "Retire"
end
scenario 'Display proposal without action buttons inside accordion proposal tab when current user is not proposal author', :js do
proposal = create(:proposal)
create(:follow, followable: proposal, user: @user)
login_as @user
visit user_path(@user, filter: "follows")
click_link 'Citizen proposals'
expect(page).to have_content proposal.title
expect(page).not_to have_link "Send notification"
expect(page).not_to have_link "Retire"
end
end
describe 'Budget Investments' do
@@ -484,35 +460,22 @@ feature 'Users' do
expect(page).to have_content('1 Following')
end
scenario 'Display accordion budget investment tab when user is following one budget investment at least' do
scenario 'Display budget investment tab when user is following one budget investment at least' do
budget_investment = create(:budget_investment)
create(:follow, followable: budget_investment, user: @user)
visit user_path(@user, filter: "follow")
visit user_path(@user, filter: "follows")
expect(page).to have_link('Investments', href: "#")
expect(page).to have_link('Investments', href: "#investments")
end
scenario 'Not display accordion budget investment tab when user is not following any budget investment' do
visit user_path(@user, filter: "follow")
scenario 'Not display budget investment tab when user is not following any budget investment' do
visit user_path(@user, filter: "follows")
expect(page).not_to have_link('Investments', href: "#")
expect(page).not_to have_link('Investments', href: "#investments")
end
scenario 'Display budget investment with action buttons inside accordion budget investment tab when current user is a verified user and author', :js do
user = create(:user, :level_two)
budget_investment = create(:budget_investment, author: user)
create(:follow, followable: budget_investment, user: user)
login_as user
visit user_path(user, filter: "follows")
click_link 'Investments'
expect(page).to have_link budget_investment.title
expect(page).to have_link "Delete"
end
scenario 'Display budget investment with action buttons inside accordion budget investment tab when there is no logged user', :js do
scenario 'Display budget investment with link to budget investment' do
user = create(:user, :level_two)
budget_investment = create(:budget_investment, author: user)
create(:follow, followable: budget_investment, user: user)
@@ -521,22 +484,7 @@ feature 'Users' do
click_link 'Investments'
expect(page).to have_link budget_investment.title
expect(page).not_to have_link "Delete"
end
scenario 'Display budget investment without action buttons inside accordion budget investment tab when current user is not budget investment author', :js do
user = create(:user, :level_two)
budget_investment = create(:budget_investment)
create(:follow, followable: budget_investment, user: user)
login_as user
visit user_path(user, filter: "follows")
click_link 'Investments'
expect(page).to have_link budget_investment.title
expect(page).not_to have_link "Delete"
end
end
end

View File

@@ -28,7 +28,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
within "##{dom_id(followable)}" do
expect(page).to have_link("Follow")
expect(page).to have_link("Follow #{followable.model_name.human.downcase}")
end
end
@@ -37,8 +37,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
login_as(user)
visit send(followable_path, arguments)
expect(page).to have_link("Follow")
expect(page).to have_link("Follow #{followable.model_name.human.downcase}")
end
scenario "Should display unfollow after user clicks on follow button", :js do
@@ -47,10 +46,10 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
within "##{dom_id(followable)}" do
click_link "Follow"
click_link("Follow #{followable.model_name.human.downcase}")
expect(page).not_to have_link "Follow"
expect(page).to have_link "Unfollow"
expect(page).not_to have_link("Follow")
expect(page).to have_link("Following")
end
end
@@ -60,7 +59,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
within "##{dom_id(followable)}" do
click_link "Follow"
click_link("Follow #{followable.model_name.human.downcase}")
end
expect(page).to have_content strip_tags(t("shared.followable.#{followable_class_name}.create.notice_html"))
@@ -73,7 +72,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
expect(page).to have_link("Unfollow")
expect(page).to have_link("Following")
end
scenario "Should update follow button and show destroy notice after user clicks on unfollow button", :js do
@@ -83,10 +82,10 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
within "##{dom_id(followable)}" do
click_link "Unfollow"
click_link("Unfollow #{followable.model_name.human.downcase}")
expect(page).not_to have_link "Unfollow"
expect(page).to have_link "Follow"
expect(page).not_to have_link("Unfollow")
expect(page).to have_link("Follow #{followable.model_name.human.downcase}")
end
end
@@ -97,7 +96,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa
visit send(followable_path, arguments)
within "##{dom_id(followable)}" do
click_link "Unfollow"
click_link("Unfollow #{followable.model_name.human.downcase}")
end
expect(page).to have_content strip_tags(t("shared.followable.#{followable_class_name}.destroy.notice_html"))

View File

@@ -9,6 +9,9 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
let!(:imageable) { create(imageable_factory_name) }
before do
Setting['feature.allow_images'] = true
imageable_path_arguments&.each do |argument_name, path_to_value|
arguments.merge!("#{argument_name}": imageable.send(path_to_value))
end
@@ -16,6 +19,10 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
imageable.update(author: user) if imageable.respond_to?(:author)
end
after do
Setting['feature.allow_images'] = nil
end
describe "at #{path}" do
scenario "Should show new image link when imageable has not an associated image defined" do