Skip to content

Commit

Permalink
Fix builds and tests for all Sitecore versions
Browse files Browse the repository at this point in the history
  • Loading branch information
adeneys committed Feb 19, 2020
1 parent 0c0274e commit 8c1667d
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 16 deletions.
7 changes: 6 additions & 1 deletion Test/UnitTest/Caching/ProfanityFilterCacheFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Sitecore.Modules.WeBlog.UnitTest.Caching
{
#if FEATURE_ABSTRACTIONS
[TestFixture]
public class ProfanityFilterCacheFixture
{
Expand Down Expand Up @@ -43,7 +44,10 @@ public void WordListGet_InnerCacheHasEntries_ReturnsWords()
{
// arrange
#pragma warning disable CS0252 // Possible unintended reference comparison; left hand side needs cast
var innerCache = Mock.Of<ICache>(x => x.GetValue("wordlist_database") == "lorem|ipsum");
var innerCache = Mock.Of<ICache>(x =>
x.GetValue("wordlist_database") == "lorem|ipsum" &&
x["wordlist_database"] == "lorem|ipsum"
);
#pragma warning restore CS0252 // Possible unintended reference comparison; left hand side needs cast
var database = Mock.Of<Database>(x => x.Name == "database");
var sut = new ProfanityFilterCache(innerCache, database);
Expand Down Expand Up @@ -88,4 +92,5 @@ public void WordListSet_DatabaseIsNullAndWordsSet_SavesWordsToInnerCache()
innerCache.Verify(x => x.Add("wordlist_master", "lorem|ipsum"));
}
}
#endif
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Joel.Net;
#if FEATURE_ABSTRACTIONS
using Joel.Net;
using Moq;
using NUnit.Framework;
using Sitecore.Abstractions;
Expand Down Expand Up @@ -78,7 +79,7 @@ public void Process_WhenCalled_InitializesAkismetApi()
sut.Process(args);

// assert
akismetApiMock.Verify(x => x.Init("apikey", "link", "WeBlog/4.0.0.0"));
akismetApiMock.Verify(x => x.Init("apikey", "link", "WeBlog/4.0.1.0"));
}

[Test]
Expand Down Expand Up @@ -152,7 +153,7 @@ public void Process_CommentIsSpam_AbortsPipeline()

var akismetApiMock = new Mock<IAkismet>();

var processor = new AkismetSpamCheck(settings, linkManager, blogManager, akismetApiMock.Object);
var processor = new AkismetSpamCheck(settings, blogManager, akismetApiMock.Object, linkManager);

var item = CreateCommentItem();
var database = Mock.Of<Database>(x =>
Expand Down Expand Up @@ -198,3 +199,4 @@ private CommentItem CreateCommentItem()
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Sitecore.Modules.WeBlog.UnitTest.Pipelines.ProfanityFilter
{
#if FEATURE_ABSTRACTIONS
[TestFixture]
public class GetProfanityListFromItemFixture
{
Expand All @@ -24,7 +25,6 @@ public void Process_UnknownItem_DoesNotPopulateWords()
Assert.That(args.WordList, Is.Empty);
}


[Test]
public void Process_ValidItem_PopulatesWords()
{
Expand Down Expand Up @@ -72,4 +72,5 @@ public void Process_WordsAlreadyPopulated_DoesNothing()
Assert.That(args.WordList, Is.EquivalentTo(new[] { "dolor" }));
}
}
#endif
}
2 changes: 1 addition & 1 deletion data/packages/WeBlog sc8.x.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<PackageName>WeBlog</PackageName>
<Author>WeTeam Community</Author>
<Version>4.0.0</Version>
<Version>4.0.1</Version>
<Revision />
<License>&lt;p&gt;&lt;strong&gt;The MIT License (MIT)&lt;/strong&gt;&lt;br/&gt;
Copyright (c) 2011 - 2020 WeTeam Community
Expand Down
2 changes: 1 addition & 1 deletion data/packages/WeBlog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<PackageName>WeBlog</PackageName>
<Author>WeTeam Community</Author>
<Version>4.0.0</Version>
<Version>4.0.1</Version>
<Revision />
<License>&lt;p&gt;&lt;strong&gt;The MIT License (MIT)&lt;/strong&gt;&lt;br/&gt;
Copyright (c) 2011 - 2020 WeTeam Community
Expand Down
2 changes: 1 addition & 1 deletion sc version properties.targets
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('sc9.1'))">
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<DefineConstants>$(DefineConstants);FEATURE_ABSTRACTIONS;FEATURE_XCONNECT;FEATURE_NVELOCITY;SOLR</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_ABSTRACTIONS;FEATURE_XCONNECT;FEATURE_NVELOCITY;SOLR;SC91</DefineConstants>
<OutputPath>bin\sc91\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('sc9.2'))">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/configuration/sitecore/contentSearch/indexConfigurations/defaultWeBlogSolrIndexConfiguration/fieldReaders/@type">
</xsl:template>

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
2 changes: 2 additions & 0 deletions src/Sitecore.Modules.WeBlog/Caching/ProfanityFilterCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ public ProfanityFilterCache(string name, long maxSize) : base(name, maxSize)
_database = ContentHelper.GetContentDatabase();
}

#if FEATURE_ABSTRACTIONS
public ProfanityFilterCache(ICache innerCache, Database database) : base(innerCache)
{
_database = database ?? ContentHelper.GetContentDatabase();
}
#endif

protected string CacheName
{
Expand Down
2 changes: 2 additions & 0 deletions src/Sitecore.Modules.WeBlog/Caching/SimpleCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ public class SimpleCache : CustomCache
{
public SimpleCache(string name, long maxSize) : base(name, maxSize) { }

#if FEATURE_ABSTRACTIONS
public SimpleCache(ICache innerCache) : base(innerCache) { }
#endif

public string Get(string cacheKey)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,63 @@
using System.Diagnostics;
using System.Reflection;
using Joel.Net;
using Sitecore.Abstractions;
using Sitecore.DependencyInjection;
using Sitecore.Diagnostics;
using Sitecore.Links;
using Sitecore.Modules.WeBlog.Configuration;
using Sitecore.Modules.WeBlog.Extensions;
using Sitecore.Modules.WeBlog.Managers;
using Sitecore.Sites;

#if FEATURE_ABSTRACTIONS
using Sitecore.Abstractions;
using Sitecore.DependencyInjection;
#endif

namespace Sitecore.Modules.WeBlog.Pipelines.CreateComment
{
public class AkismetSpamCheck : ICreateCommentProcessor
{
private IWeBlogSettings _settings = null;
private BaseLinkManager _linkManager = null;
private IAkismet _akismetApi = null;
private IBlogManager _blogManager = null;

#if FEATURE_ABSTRACTIONS
private BaseLinkManager _linkManager = null;
#endif

public AkismetSpamCheck()
: this(null, null, null, null)
: this(null, null, null
#if FEATURE_ABSTRACTIONS
, null
#endif
)
{
}

[Obsolete("Use ctor(IWeBlogSettings, BaseLinkManager, IBlogManager, IAkismet) instead.")]
public AkismetSpamCheck(IWeBlogSettings settings)
: this(settings, null, null, null)
: this(settings, null, null
#if FEATURE_ABSTRACTIONS
, null
#endif
)
{
}

public AkismetSpamCheck(IWeBlogSettings settings, BaseLinkManager linkManager, IBlogManager blogManager, IAkismet akismetApi)
public AkismetSpamCheck(IWeBlogSettings settings, IBlogManager blogManager, IAkismet akismetApi
#if FEATURE_ABSTRACTIONS
, BaseLinkManager linkManager
#endif

)
{
_settings = settings ?? WeBlogSettings.Instance;
_linkManager = linkManager ?? ServiceLocator.ServiceProvider.GetService(typeof(BaseLinkManager)) as BaseLinkManager;
_blogManager = blogManager ?? ManagerFactory.BlogManagerInstance;
_akismetApi = akismetApi;

#if FEATURE_ABSTRACTIONS
_linkManager = linkManager ?? ServiceLocator.ServiceProvider.GetService(typeof(BaseLinkManager)) as BaseLinkManager;
#endif
}

public void Process(CreateCommentArgs args)
Expand All @@ -57,7 +79,12 @@ public void Process(CreateCommentArgs args)

var urlOptions = UrlOptions.DefaultOptions;
urlOptions.AlwaysIncludeServerUrl = true;

#if FEATURE_ABSTRACTIONS
var url = _linkManager.GetItemUrl(_blogManager.GetCurrentBlog(), urlOptions);
#else
var url = LinkManager.GetItemUrl(_blogManager.GetCurrentBlog(), urlOptions);
#endif

api.Init(_settings.AkismetAPIKey, url, "WeBlog/" + version);

Expand Down
3 changes: 3 additions & 0 deletions src/Sitecore.Modules.WeBlog/Sitecore.Modules.WeBlog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
<CodeAnalysisDictionary Include="CustomDictionary.xml" />
<Content Include="App_Config\Include\WeBlog.config.delivery.xslt" />
<Content Include="App_Config\Include\WeBlog.config.noremote.xslt" />
<Content Include="App_Config\Include\WeBlog.ContentSearch.Solr.config.9.1.xslt" />
<Content Include="sitecore modules\web\WeBlog\Comment.svc" />
<Content Include="sitecore modules\web\WeBlog\TagField\chosen-sprite.png" />
<Content Include="sitecore modules\web\WeBlog\TagField\chosen.jquery.js" />
Expand Down Expand Up @@ -477,6 +478,8 @@
<!-- Remove Scriban mail action pipeline config if types are not available -->
<Delete Files="$(SitecorePath)\App_Config\Include\WeBlog.ScribanMailAction.config" Condition="$(DefineConstants.Contains('FEATURE_ABSTRACTIONS')) != true" />
<CallTarget Targets="DeploySC8xEE" Condition="$(Configuration.Contains('sc8.0')) or $(Configuration.Contains('sc8.1')) or $(Configuration.Contains('sc8.2'))" />
<!-- Transform content search config for specific Sitecore versions -->
<XslTransformation XslInputPath="App_Config\Include\WeBlog.ContentSearch.Solr.config.9.1.xslt" XmlInputPaths="App_Config\Include\WeBlog.ContentSearch.Solr.config" OutputPaths="$(SitecorePath)\App_Config\Include\WeBlog.ContentSearch.Solr.config" Condition="$(SitecorePath) != '' AND $(DefineConstants.Contains('SC91'))" />
</Target>
<Target Name="ContentDeliveryConfig">
<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.0.1.*")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.1.0")]

0 comments on commit 8c1667d

Please sign in to comment.