diff --git a/app/controllers/communities_controller.rb b/app/controllers/communities_controller.rb index 72c368eb1..68948cc65 100644 --- a/app/controllers/communities_controller.rb +++ b/app/controllers/communities_controller.rb @@ -7,6 +7,7 @@ class CommunitiesController < ApplicationController skip_authorization_check def show + redirect_to root_path unless Setting['community'].present? end private diff --git a/app/views/communities/_access_button.html.erb b/app/views/communities/_access_button.html.erb index 9c4d90a5e..a5a55786e 100644 --- a/app/views/communities/_access_button.html.erb +++ b/app/views/communities/_access_button.html.erb @@ -1,6 +1,8 @@ - -

<%= t("community.sidebar.title") %>

-

- <%= t("community.sidebar.description") %> -

-<%= link_to t("community.sidebar.button_to_access"), community_path(community_id), class: 'button hollow expanded' %> +<% if feature?("community") %> + +

<%= t("community.sidebar.title") %>

+

+ <%= t("community.sidebar.description") %> +

+ <%= link_to t("community.sidebar.button_to_access"), community_path(community_id), class: 'button hollow expanded' %> +<% end %> diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 678744bb2..ca4fac4fb 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -36,6 +36,7 @@ Setting.create(key: 'feature.facebook_login', value: "true") Setting.create(key: 'feature.google_login', value: "true") Setting.create(key: 'feature.signature_sheets', value: "true") Setting.create(key: 'feature.legislation', value: "true") +Setting.create(key: 'feature.community', value: "true") Setting.create(key: 'per_page_code_head', value: "") Setting.create(key: 'per_page_code_body', value: "") Setting.create(key: 'comments_body_max_length', value: '1000') diff --git a/db/seeds.rb b/db/seeds.rb index 718583b22..90665fdb8 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -79,6 +79,7 @@ Setting['feature.public_stats'] = true Setting['feature.budgets'] = true Setting['feature.signature_sheets'] = true Setting['feature.legislation'] = true +Setting['feature.community'] = nil # Spending proposals feature flags Setting['feature.spending_proposal_features.voting_allowed'] = nil diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index 0a2aa15ca..86e5d4dc8 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -330,6 +330,22 @@ feature 'Budget Investments' do expect(page).to have_content "Access the community" end + scenario 'Can access the community' do + Setting['feature.community'] = true + + investment = create(:budget_investment, heading: heading) + visit budget_investment_path(budget_id: budget.id, id: investment.id) + expect(page).to have_content "Access the community" + + Setting['feature.community'] = false + end + + scenario 'Can not access the community' do + investment = create(:budget_investment, heading: heading) + visit budget_investment_path(budget_id: budget.id, id: investment.id) + expect(page).not_to have_content "Access the community" + end + scenario "Don't display flaggable buttons" do investment = create(:budget_investment, heading: heading) diff --git a/spec/features/communities_spec.rb b/spec/features/communities_spec.rb index 7ea966e75..7678c5678 100644 --- a/spec/features/communities_spec.rb +++ b/spec/features/communities_spec.rb @@ -2,6 +2,14 @@ require 'rails_helper' feature 'Communities' do + background do + Setting['feature.community'] = true + end + + after do + Setting['feature.community'] = nil + end + context 'Show' do scenario 'Should display default content' do @@ -102,6 +110,15 @@ feature 'Communities' do end end + scenario 'Should redirect root path when communities are disabled' do + proposal = create(:proposal) + community = proposal.community + + visit community_path(community) + + expect(current_path).to eq(root_path) + end + end end diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 291de5022..63050c43f 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -63,7 +63,6 @@ feature 'Proposals' do expect(page.html).to include "#{proposal.title}" expect(page).not_to have_selector ".js-flag-actions" expect(page).not_to have_selector ".js-follow" - expect(page).to have_content "Access the community" within('.social-share-button') do expect(page.all('a').count).to be(4) # Twitter, Facebook, Google+, Telegram @@ -90,6 +89,22 @@ feature 'Proposals' do expect(current_path).to_not eq(old_path) expect(current_path).to eq(right_path) end + + scenario 'Can access the community' do + Setting['feature.community'] = true + + proposal = create(:proposal) + visit proposal_path(proposal) + expect(page).to have_content "Access the community" + + Setting['feature.community'] = false + end + + scenario 'Can not access the community' do + proposal = create(:proposal) + visit proposal_path(proposal) + expect(page).not_to have_content "Access the community" + end end context "Embedded video" do