Merge branch 'stable' into develop

This commit is contained in:
Dennis Schubert 2015-05-25 04:18:46 +02:00
commit f9f73f56db
9 changed files with 191 additions and 77 deletions

View file

@ -55,7 +55,6 @@ Ruby 2.0 is no longer officially supported.
* Fix a freeze in new post parsing [#5965](https://github.com/diaspora/diaspora/pull/5965)
* Add case insensitive unconfirmed email addresses as authentication key [#5967](https://github.com/diaspora/diaspora/pull/5967)
* Fix liking on single post views when accessed via GUID [#5978](https://github.com/diaspora/diaspora/pull/5978)
* Gracefully handle mailer failures when a like is already deleted again [#5983](https://github.com/diaspora/diaspora/pull/5983)
## Features
* Hide post title of limited post in comment notification email [#5843](https://github.com/diaspora/diaspora/pull/5843)
@ -70,6 +69,7 @@ Ruby 2.0 is no longer officially supported.
* Add a "Manage followed tags" page to mass unfollow tags in the mobile interface [#5945](https://github.com/diaspora/diaspora/pull/5945)
* Add popover/tooltip about email visibility to registration/settings page [#5956](https://github.com/diaspora/diaspora/pull/5956)
* Fetch person posts on sharing request [#5960](https://github.com/diaspora/diaspora/pull/5960)
* Introduce 'authorized' configuration option for services [#5985](https://github.com/diaspora/diaspora/pull/5985)
# 0.5.0.1

View file

@ -98,7 +98,7 @@ class StatisticsPresenter
def all_services_helper
result = {}
Configuration::KNOWN_SERVICES.each {|service, options|
result[service.to_s] = AppConfig["services.#{service}.enable"]
result[service.to_s] = AppConfig.show_service?(service, nil)
}
result
end
@ -109,13 +109,13 @@ class StatisticsPresenter
def available_services
Configuration::KNOWN_SERVICES.select {|service|
AppConfig["services.#{service}.enable"]
AppConfig.show_service?(service, nil)
}.map(&:to_s)
end
def legacy_services
Configuration::KNOWN_SERVICES.each_with_object({}) {|service, result|
result[service.to_s] = AppConfig["services.#{service}.enable"]
result[service.to_s] = AppConfig.show_service?(service, nil)
}
end

View file

@ -4,6 +4,7 @@
- if AppConfig.configured_services.count > 0
- AppConfig.configured_services.each do |provider|
- if AppConfig.show_service?(provider, current_user)
%h3= t("services.provider.#{provider}")
- services_for_provider = @services.select{|x| x.provider == provider.to_s}
- if services_for_provider.count > 0

View file

@ -57,6 +57,7 @@
#right_service_icons
- AppConfig.configured_services.each do |service|
- if AppConfig.show_service?(service, current_user)
- unless current_user.services.any?{|x| x.provider == service}
= link_to(content_tag(:div, nil, :class => "social_media_logos-#{service.to_s.downcase}-24x24", :title => service.to_s.titleize), "/auth/#{service}")

View file

@ -145,18 +145,22 @@ defaults:
app_id:
secret:
open_graph_namespace: 'joindiaspora'
authorized: false
twitter:
enable: false
key:
secret:
authorized: true
tumblr:
enable: false
key:
secret:
authorized: true
wordpress:
enable: false
key:
secret:
authorized: true
mail:
enable: false
sender_address: 'no-reply@example.org'
@ -210,6 +214,7 @@ test:
enable: true
app_id: 'fake'
secret: 'sdoigjosdfijg'
authorized: true
mail:
enable: true
integration1:

View file

@ -532,6 +532,13 @@ configuration: ## Section
#app_id: 'abcdef'
#secret: 'change_me'
## This setting is required to define whether the Facebook app has permissions to post
## false == No permissions (default)
## true == Permissions for all users to post. App MUST have 'publish_actions' approved by Facebook!
## "username" == Set to local username to allow a single user to cross-post. The person who has created
## the Facebook app will always be able to cross-post, even without 'publish_actions'.
#authorized: false
## OAuth credentials for Twitter
twitter: ## Section

View file

@ -34,6 +34,13 @@ module Configuration
end
attr_writer :configured_services
def show_service?(service, user)
return false unless self["services.#{service}.enable"]
# Return true only if 'authorized' is true or equal to user username
(user && self["services.#{service}.authorized"] == user.username) ||
self["services.#{service}.authorized"] == true
end
def secret_token
if heroku?
return ENV['SECRET_TOKEN'] if ENV['SECRET_TOKEN']

View file

@ -70,6 +70,39 @@ describe Configuration::Methods do
end
end
describe "#show_service" do
before do
AppConfig.services.twitter.authorized = true
AppConfig.services.twitter.enable = true
AppConfig.services.facebook.authorized = true
AppConfig.services.facebook.enable = true
AppConfig.services.wordpress.authorized = false
AppConfig.services.wordpress.enable = true
AppConfig.services.tumblr.authorized = "alice"
AppConfig.services.tumblr.enable = true
end
it "shows service with no authorized key" do
expect(AppConfig.show_service?("twitter", bob)).to be_truthy
end
it "shows service with authorized key true" do
expect(AppConfig.show_service?("facebook", bob)).to be_truthy
end
it "doesn't show service with authorized key false" do
expect(AppConfig.show_service?("wordpress", bob)).to be_falsey
end
it "doesn't show service with authorized key not equal to username" do
expect(AppConfig.show_service?("tumblr", bob)).to be_falsey
end
it "shows service with authorized key equal to username" do
expect(AppConfig.show_service?("tumblr", alice)).to be_truthy
end
end
describe "#version_string" do
before do
@version = double

View file

@ -1,53 +1,112 @@
require 'spec_helper'
require "spec_helper"
describe StatisticsPresenter do
before do
@presenter = StatisticsPresenter.new
end
describe '#as_json' do
it 'works' do
describe "#as_json" do
it "works" do
expect(@presenter.as_json).to be_present
expect(@presenter.as_json).to be_a Hash
end
end
describe '#statistics contents' do
describe "#statistics contents" do
before do
AppConfig.privacy.statistics.user_counts = false
AppConfig.privacy.statistics.post_counts = false
AppConfig.privacy.statistics.comment_counts = false
end
it 'provides generic pod data in json' do
expect(@presenter.as_json).to eq({
it "provides generic pod data in json" do
expect(@presenter.as_json).to eq(
"name" => AppConfig.settings.pod_name,
"network" => "Diaspora",
"version" => AppConfig.version_string,
"registrations_open" => AppConfig.settings.enable_registrations?,
"services"=> ["facebook",],
"services" => ["facebook"],
"facebook" => true,
"tumblr" => false,
"twitter" => false,
"wordpress" => false,
})
"wordpress" => false
)
end
context 'when services are enabled' do
context "when services are enabled" do
before do
AppConfig.services = {
"facebook" => {
"enable" => true,
"authorized" => true
},
"twitter" => {"enable" => true},
"wordpress" => {"enable" => false},
"tumblr" => {
"enable" => true,
"authorized" => false
}
}
end
it "provides services in json" do
expect(@presenter.as_json).to eq(
"name" => AppConfig.settings.pod_name,
"network" => "Diaspora",
"version" => AppConfig.version_string,
"registrations_open" => AppConfig.settings.enable_registrations?,
"services" => %w(twitter facebook),
"facebook" => true,
"twitter" => true,
"tumblr" => false,
"wordpress" => false
)
end
end
context "when some services are set to username authorized" do
before do
AppConfig.services = {
"facebook" => {
"enable" => true,
"authorized" => "bob"
},
"twitter" => {"enable" => true},
"wordpress" => {
"enable" => true,
"authorized" => "alice"
},
"tumblr" => {
"enable" => true,
"authorized" => false
}
}
end
it "provides services in json" do
expect(@presenter.as_json).to eq(
"name" => AppConfig.settings.pod_name,
"network" => "Diaspora",
"version" => AppConfig.version_string,
"registrations_open" => AppConfig.settings.enable_registrations?,
"services" => ["twitter"],
"facebook" => false,
"twitter" => true,
"tumblr" => false,
"wordpress" => false
)
end
end
context "when counts are enabled" do
before do
AppConfig.privacy.statistics.user_counts = true
AppConfig.privacy.statistics.post_counts = true
AppConfig.privacy.statistics.comment_counts = true
AppConfig.services = {
"facebook" => {"enable" => true},
"twitter" => {"enable" => true},
"wordpress" => {"enable" => false},
"tumblr" => {"enable" => false}
}
end
it 'provides generic pod data and counts in json' do
expect(@presenter.as_json).to eq({
it "provides generic pod data and counts in json" do
expect(@presenter.as_json).to eq(
"name" => AppConfig.settings.pod_name,
"network" => "Diaspora",
"version" => AppConfig.version_string,
@ -57,20 +116,21 @@ describe StatisticsPresenter do
"active_users_monthly" => User.monthly_actives.count,
"local_posts" => @presenter.local_posts,
"local_comments" => @presenter.local_comments,
"services" => ["twitter","facebook"],
"services" => ["facebook"],
"facebook" => true,
"twitter" => true,
"twitter" => false,
"tumblr" => false,
"wordpress" => false
})
)
end
end
context 'when registrations are closed' do
context "when registrations are closed" do
before do
AppConfig.settings.enable_registrations = false
end
it 'should mark open_registrations to be false' do
it "should mark open_registrations to be false" do
expect(@presenter.open_registrations?).to be false
end
end