Add community to Global Settings

This commit is contained in:
taitus
2017-08-29 16:23:58 +02:00
parent dcaa10147a
commit e1a7f9c58c
7 changed files with 60 additions and 7 deletions

View File

@@ -7,6 +7,7 @@ class CommunitiesController < ApplicationController
skip_authorization_check
def show
redirect_to root_path unless Setting['community'].present?
end
private

View File

@@ -1,6 +1,8 @@
<div class="sidebar-divider"></div>
<h2><%= t("community.sidebar.title") %></h2>
<p>
<%= t("community.sidebar.description") %>
</p>
<%= link_to t("community.sidebar.button_to_access"), community_path(community_id), class: 'button hollow expanded' %>
<% if feature?("community") %>
<div class="sidebar-divider"></div>
<h2><%= t("community.sidebar.title") %></h2>
<p>
<%= t("community.sidebar.description") %>
</p>
<%= link_to t("community.sidebar.button_to_access"), community_path(community_id), class: 'button hollow expanded' %>
<% end %>

View File

@@ -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')

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -63,7 +63,6 @@ feature 'Proposals' do
expect(page.html).to include "<title>#{proposal.title}</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