From 5ea998a382808fabab3ee05f9ade74744a07c35a Mon Sep 17 00:00:00 2001 From: Dennis Schubert Date: Tue, 23 Oct 2012 00:29:10 +0200 Subject: [PATCH] Change 'unless' to 'if' again because 'unless' is wrong here. Also, add some specs and add it to the changelog. --- Changelog.md | 1 + app/models/user.rb | 2 +- spec/models/user_spec.rb | 53 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 0bc9d7d3b..ddf5e5295 100644 --- a/Changelog.md +++ b/Changelog.md @@ -15,6 +15,7 @@ ### Other * MessagesController. [#3657](https://github.com/diaspora/diaspora/pull/3657) +* **Fixed setting:** `follow_diasporahq` has now to be set to `true` to enable following the DiasporaHQ account. Was `false` ## Features diff --git a/app/models/user.rb b/app/models/user.rb index f37457d07..a26f6e6d9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -410,7 +410,7 @@ class User < ActiveRecord::Base self.aspects.create(:name => I18n.t('aspects.seed.work')) aq = self.aspects.create(:name => I18n.t('aspects.seed.acquaintances')) - unless AppConfig.settings.follow_diasporahq + if AppConfig.settings.follow_diasporahq? default_account = Webfinger.new('diasporahq@joindiaspora.com').fetch self.share_with(default_account, aq) if default_account end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 18d994566..905ec7295 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -870,6 +870,59 @@ describe User do end end + describe "#seed_aspects" do + describe "create aspects" do + let(:user) { + user = FactoryGirl.create(:user) + user.seed_aspects + user + } + + [I18n.t('aspects.seed.family'), I18n.t('aspects.seed.friends'), + I18n.t('aspects.seed.work'), I18n.t('aspects.seed.acquaintances')].each do |aspect_name| + it "creates an aspect named #{aspect_name} for the user" do + user.aspects.find_by_name(aspect_name).should_not be_nil + end + end + end + + describe "diasporahq sharing" do + let(:user) { + FactoryGirl.create(:user) + } + + before(:each) do + @old_followhq_value = AppConfig.settings.follow_diasporahq? + end + + after(:each) do + AppConfig.settings.follow_diasporahq = @old_followhq_value + end + + context "with sharing with diasporahq enabled" do + it "should start sharing with the diasporahq account" do + AppConfig.settings.follow_diasporahq = true + + wf_mock = mock + wf_mock.should_receive(:fetch) + Webfinger.should_receive(:new).and_return(wf_mock) + + user.seed_aspects + end + end + + context "with sharing with diasporahq enabled" do + it "should not start sharing with the diasporahq account" do + AppConfig.settings.follow_diasporahq = false + + Webfinger.should_not_receive(:new) + + user.seed_aspects + end + end + end + end + context "close account" do before do @user = bob