Merge branch '1.9.x' into dev

Conflicts:
	src/Orchard.Tests.Modules/Users/Services/MembershipServiceTests.cs
This commit is contained in:
Sebastien Ros
2015-07-31 17:50:22 -07:00
8 changed files with 41 additions and 50 deletions

View File

@@ -74,7 +74,6 @@ namespace Orchard.Tests.Modules.Users.Controllers {
builder.RegisterType<UserPartHandler>().As<IContentHandler>();
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
builder.RegisterInstance(new Work<IEnumerable<IShapeTableEventHandler>>(resolve => _container.Resolve<IEnumerable<IShapeTableEventHandler>>())).AsSelf();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();

View File

@@ -30,6 +30,7 @@ using Orchard.UI.PageClass;
using Orchard.Users.Handlers;
using Orchard.Users.Models;
using Orchard.Users.Services;
using Orchard.Tests.ContentManagement;
using Orchard.Services;
namespace Orchard.Tests.Modules.Users.Services {
@@ -41,19 +42,6 @@ namespace Orchard.Tests.Modules.Users.Services {
private ISession _session;
private IContainer _container;
private StubClock _clock;
public class TestSessionLocator : ISessionLocator {
private readonly ISession _session;
public TestSessionLocator(ISession session) {
_session = session;
}
public ISession For(Type entityType) {
return _session;
}
}
[TestFixtureSetUp]
public void InitFixture() {
var databaseFileName = System.IO.Path.GetTempFileName();
@@ -98,12 +86,19 @@ namespace Orchard.Tests.Modules.Users.Services {
builder.RegisterType<InfosetHandler>().As<IContentHandler>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
_container = builder.Build();
_membershipValidationService = _container.Resolve<IMembershipValidationService>();
_membershipService = _container.Resolve<IMembershipService>();
}
[TearDown]
public void Cleanup() {
if (_container != null)
_container.Dispose();
}
[Test]
public void CreateUserShouldAllocateModelAndCreateRecords() {
var user = _membershipService.CreateUser(new CreateUserParams("a", "b", "c", null, null, true));

View File

@@ -34,6 +34,7 @@ using Orchard.Users.Services;
using Orchard.Services;
using Orchard.Tests.Messaging;
using Orchard.Tests.Modules.Stubs;
using Orchard.Tests.ContentManagement;
namespace Orchard.Tests.Modules.Users.Services {
[TestFixture]
@@ -47,19 +48,6 @@ namespace Orchard.Tests.Modules.Users.Services {
private IContainer _container;
private CultureInfo _currentCulture;
public class TestSessionLocator : ISessionLocator {
private readonly ISession _session;
public TestSessionLocator(ISession session) {
_session = session;
}
public ISession For(Type entityType) {
return _session;
}
}
[TestFixtureSetUp]
public void InitFixture() {
_currentCulture = Thread.CurrentThread.CurrentCulture;
@@ -109,9 +97,8 @@ namespace Orchard.Tests.Modules.Users.Services {
builder.RegisterInstance(ShellSettingsUtility.CreateEncryptionEnabled());
_session = _sessionFactory.OpenSession();
_session.BeginTransaction();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();
_container = builder.Build();
_membershipService = _container.Resolve<IMembershipService>();
_userService = _container.Resolve<IUserService>();
@@ -119,8 +106,8 @@ namespace Orchard.Tests.Modules.Users.Services {
[TearDown]
public void TearDown() {
_session.Transaction.Commit();
_session.Transaction.Dispose();
if (_container != null)
_container.Dispose();
}
[Test]

View File

@@ -498,10 +498,10 @@ namespace Orchard.Core.Shapes {
var totalPageCount = pageSize > 0 ? (int)Math.Ceiling(TotalItemCount / pageSize) : 1;
var firstText = FirstText ?? T("<<");
var previousText = PreviousText ?? T("<");
var nextText = NextText ?? T(">");
var lastText = LastText ?? T(">>");
var firstText = FirstText ?? T("&lt;&lt;");
var previousText = PreviousText ?? T("&lt;");
var nextText = NextText ?? T("&gt;");
var lastText = LastText ?? T("&gt;&gt;");
var gapText = GapText ?? T("...");
var routeData = new RouteValueDictionary(Html.ViewContext.RouteData.Values);

View File

@@ -53,7 +53,10 @@ namespace Orchard.Localization.Controllers {
var contentItemTranslation = _contentManager.New<LocalizationPart>(masterContentItem.ContentType);
contentItemTranslation.MasterContentItem = masterContentItem;
var content = _contentManager.BuildEditor(contentItemTranslation);
// build the editor using the master content item so that
// the form is pre-populated with the original values
var content = _contentManager.BuildEditor(masterContentItem);
return View(content);
}

View File

@@ -8,7 +8,7 @@ using StackExchange.Redis;
namespace Orchard.Redis.Configuration {
public class RedisConnectionProvider : IRedisConnectionProvider {
private static ConcurrentDictionary<string, ConnectionMultiplexer> _connectionMultiplexers = new ConcurrentDictionary<string, ConnectionMultiplexer>();
private static ConcurrentDictionary<string, Lazy<ConnectionMultiplexer>> _connectionMultiplexers = new ConcurrentDictionary<string, Lazy<ConnectionMultiplexer>>();
private readonly ShellSettings _shellSettings;
public RedisConnectionProvider(ShellSettings shellSettings) {
@@ -37,12 +37,16 @@ namespace Orchard.Redis.Configuration {
throw new ArgumentNullException("connectionString");
}
var connectionMultiplexer = _connectionMultiplexers.GetOrAdd(connectionString, cfg => {
Logger.Debug("Creating a new cache client for: {0}", connectionString);
return ConnectionMultiplexer.Connect(connectionString);
});
// when using ConcurrentDictionary, multiple threads can create the value
// at the same time, so we need to pass a Lazy so that it's only
// the object which is added that will create a ConnectionMultiplexer,
// even when a delegate is passed
return connectionMultiplexer;
return _connectionMultiplexers.GetOrAdd(connectionString,
new Lazy<ConnectionMultiplexer>(() => {
Logger.Debug("Creating a new cache client for: {0}", connectionString);
return ConnectionMultiplexer.Connect(connectionString);
})).Value;
}
}
}

View File

@@ -15,7 +15,7 @@ namespace Orchard.Redis.OutputCache {
[OrchardFeature("Orchard.Redis.OutputCache")]
[OrchardSuppressDependency("Orchard.OutputCache.Services.DefaultCacheStorageProvider")]
public class RedisOutputCacheStorageProvider : Component, IOutputCacheStorageProvider {
public class RedisOutputCacheStorageProvider : IOutputCacheStorageProvider {
private readonly ShellSettings _shellSettings;
private readonly IRedisConnectionProvider _redisConnectionProvider;
@@ -23,18 +23,22 @@ namespace Orchard.Redis.OutputCache {
public const string ConnectionStringKey = "Orchard.Redis.OutputCache";
private readonly string _connectionString;
private readonly ConnectionMultiplexer _connectionMultiplexer;
public RedisOutputCacheStorageProvider(ShellSettings shellSettings, IRedisConnectionProvider redisConnectionProvider) {
_shellSettings = shellSettings;
_redisConnectionProvider = redisConnectionProvider;
_connectionString = _redisConnectionProvider.GetConnectionString(ConnectionStringKey);
_connectionMultiplexer = _redisConnectionProvider.GetConnection(_connectionString);
Logger = NullLogger.Instance;
}
public ILogger Logger { get; set; }
public IDatabase Database {
get {
return _redisConnectionProvider.GetConnection(_connectionString).GetDatabase();
return _connectionMultiplexer.GetDatabase();
}
}
@@ -97,9 +101,8 @@ namespace Orchard.Redis.OutputCache {
_keysCache = new HashSet<string>();
var prefix = GetLocalizedKey("");
var connection = _redisConnectionProvider.GetConnection(_connectionString);
foreach (var endPoint in connection.GetEndPoints()) {
var server = connection.GetServer(endPoint);
foreach (var endPoint in _connectionMultiplexer.GetEndPoints()) {
var server = _connectionMultiplexer.GetServer(endPoint);
foreach (var key in server.Keys(pattern: GetLocalizedKey("*"))) {
_keysCache.Add(key.ToString().Substring(prefix.Length));
}

View File

@@ -1,6 +1,6 @@
@{
Model.PreviousText = T("<");
Model.NextText = T(">");
Model.PreviousText = T("&lt;");
Model.NextText = T("&gt;");
var routeData = new RouteValueDictionary(ViewContext.RouteData.Values);
var queryString = ViewContext.HttpContext.Request.QueryString;