Bug & layout fixes
* Index.aspx: * Title.aspx: * YavscModel.csproj: * BlogEntry.cs: * yavsc.scrollnotif.js: * AccountController.cs: * BlogEntryCollection.cs: refactoring * yavsc.tags.js: Implements a js call to the tag & untag methods * PostActions.ascx: a better html structure * BasePost.cs: refactoring: allows the "PostActions" user control to use a common base object as post reference * NpgsqlBlogProvider.cs: implements the tag methods on db * ResultPages.cs: A multi-pages result meta info when one page only * yavsc.circles.js: * AccountController.cs: code formatting * BlogsController.cs: Untag a post * style.css: yastyle, yet a better one. * BlogsController.cs: View the Title after edition * App.master: * UserPosts.aspx: a nicer html structure * yavsc.js: Fixes notice & dimiss js * Login.aspx: refactoring * Edit.aspx: better html * UserPost.aspx: A promess to be allowed to tag. * Web.csproj: Adds yavsc.tags.js and yavsc.scrollnotifs.js to the project decription. * BlogManager.cs: Makes the blog manager expose of the new `UnTag` method * BlogProvider.cs: introduces a method to `untag` * FindBlogEntryFlags.cs: Find post entry by tag * LocalizedText.resx: * LocalizedText.Designer.cs: new translations: - "Tag" - "Edit" * LocalizedText.fr.resx: * LocalizedText.fr.Designer.cs: nouvelles traductions: - "Tag" - "Edit" * Profile.cs: a nicer stack trace at buggy usage
This commit is contained in:
parent
c962998aaa
commit
d04a68db01
41 changed files with 894 additions and 270 deletions
|
|
@ -24,27 +24,55 @@ using Yavsc.Model.Blogs;
|
|||
using Yavsc.Controllers;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Security;
|
||||
using System.Web.Configuration;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace TestAPI
|
||||
namespace Yavsc
|
||||
{
|
||||
|
||||
[TestFixture ()]
|
||||
public class BlogUnitTest
|
||||
public class AccountUnitTestCase
|
||||
{
|
||||
|
||||
public string UserName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Password { get; set; }
|
||||
|
||||
|
||||
AccountController accountController;
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
|
||||
public AccountController AccountController {
|
||||
get {
|
||||
return accountController;
|
||||
}
|
||||
}
|
||||
string defaultMembershipProvider = null;
|
||||
[Test]
|
||||
public virtual void Init()
|
||||
{
|
||||
webSource = new XSPWebSource (configurationManager.Address, configurationManager.Port, !root);
|
||||
|
||||
|
||||
var server = new ApplicationServer (webSource, configurationManager.Root) {
|
||||
Verbose = configurationManager.Verbose,
|
||||
SingleApplication = !root
|
||||
};
|
||||
string basedir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string curdir = Directory.GetCurrentDirectory ();
|
||||
string dummyVirtualPath = "/";
|
||||
string physicalPath = @"/home/paul/workspace/totem/web/";
|
||||
WebConfigurationFileMap map = new WebConfigurationFileMap ();
|
||||
map.VirtualDirectories.Add(dummyVirtualPath, new VirtualDirectoryMapping(physicalPath, true));
|
||||
Configuration configuration = WebConfigurationManager.OpenMappedWebConfiguration(map, dummyVirtualPath);
|
||||
accountController = new AccountController ();
|
||||
string da = (string) configuration.AppSettings.Settings ["DefaultAvatar"].Value;
|
||||
MembershipSection s = configuration.GetSection ("system.web/membership") as MembershipSection;
|
||||
defaultMembershipProvider = s.DefaultProvider;
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void Register ()
|
||||
public virtual void Register ()
|
||||
{
|
||||
ViewResult actionResult = accountController.Register (
|
||||
new Yavsc.Model.RolesAndMembers.RegisterViewModel () {
|
||||
|
|
@ -53,7 +81,7 @@ namespace TestAPI
|
|||
IsApprouved = true
|
||||
},
|
||||
"/testreturnurl") as ViewResult;
|
||||
Assert.AreEqual (actionResult.ViewName, "RegistrationPending");
|
||||
Assert.AreSame ("",actionResult.ViewName);
|
||||
MembershipUser u = Membership.GetUser (UserName, false);
|
||||
Assert.NotNull (u);
|
||||
Assert.False (u.IsApproved);
|
||||
|
|
@ -64,8 +92,9 @@ namespace TestAPI
|
|||
Membership.UpdateUser (u);
|
||||
Assert.True (u.IsApproved);
|
||||
}
|
||||
|
||||
[TestFixtureTearDown()]
|
||||
public void Unregister()
|
||||
public virtual void Unregister()
|
||||
{
|
||||
ViewResult actionResult =
|
||||
accountController.Unregister (UserName, true) as ViewResult;
|
||||
52
TestAPI/BlogUnitTestCase.cs
Normal file
52
TestAPI/BlogUnitTestCase.cs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
//
|
||||
// TagTestCases.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paul@pschneider.fr>
|
||||
//
|
||||
// Copyright (c) 2015 GNU GPL
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using Yavsc.Model.Blogs;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class BlogUnitTestCase: AccountUnitTestCase
|
||||
{
|
||||
|
||||
[TestFixtureSetUp]
|
||||
void NeedAPost()
|
||||
{
|
||||
Register ();
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestCase ()
|
||||
{
|
||||
long pid = BlogManager.Post (UserName, "BlogUnitTestCase", "content", true, null);
|
||||
BlogManager.Tag (pid, "test");
|
||||
|
||||
}
|
||||
|
||||
[TestFixtureTearDown()]
|
||||
void Cleanup()
|
||||
{
|
||||
Unregister ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
90
TestAPI/TestByteA.cs
Normal file
90
TestAPI/TestByteA.cs
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
#if TEST
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using Npgsql;
|
||||
using System.Web.Configuration;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class TestByteA: IDisposable
|
||||
{
|
||||
string cnxName = "yavsc";
|
||||
|
||||
string ConnectionString { get {
|
||||
return "Server=127.0.0.1;Port=5432;Database=YavscDev;User Id=yavscdev;Password=admin;Encoding=Unicode;" ;
|
||||
// Why? not this : return WebConfigurationManager.ConnectionStrings [cnxName].ConnectionString;
|
||||
|
||||
} }
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
// create the table
|
||||
Console.WriteLine ("cnx:"+ConnectionString);
|
||||
using (NpgsqlConnection cnx = new NpgsqlConnection (ConnectionString))
|
||||
{
|
||||
cnx.Open ();
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
|
||||
cmd.CommandText = "drop table _testbytea";
|
||||
try { cmd.ExecuteNonQuery (); }
|
||||
catch (NpgsqlException) {
|
||||
}
|
||||
cmd.CommandText = "create table _testbytea( t bytea )";
|
||||
cmd.ExecuteNonQuery ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test(Description="Test storing a byte array in a Postgresql table field")]
|
||||
public void TestStoreByteA ()
|
||||
{
|
||||
byte []a = new byte[3];
|
||||
a[0]=1;
|
||||
a[1]=2;
|
||||
a[2]=3;
|
||||
using (NpgsqlConnection cnx = new NpgsqlConnection (ConnectionString)) {
|
||||
cnx.Open ();
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ())
|
||||
{
|
||||
cmd.CommandText = "insert into _testbytea (t) values (@tv)";
|
||||
cmd.Parameters.AddWithValue ("@tv", a);
|
||||
cmd.ExecuteNonQuery ();
|
||||
}
|
||||
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ())
|
||||
{
|
||||
cmd.CommandText = "select t from _testbytea";
|
||||
cmd.Parameters.AddWithValue ("@tv", a);
|
||||
|
||||
NpgsqlDataReader rdr = cmd.ExecuteReader ();
|
||||
if (!rdr.Read ())
|
||||
throw new Exception ("Read failed");
|
||||
int i = rdr.GetOrdinal ("t");
|
||||
byte []rded = (byte[]) rdr.GetValue (i);
|
||||
if (rded.Length!=a.Length)
|
||||
throw new Exception("Lengthes don't match");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable implementation
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void Dispose ()
|
||||
{
|
||||
// drop the table
|
||||
using (NpgsqlConnection cnx = new NpgsqlConnection (ConnectionString)) {
|
||||
cnx.Open ();
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
|
||||
cmd.CommandText = "drop table _testbytea";
|
||||
cmd.ExecuteNonQuery ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
124
TestAPI/Web.config
Normal file
124
TestAPI/Web.config
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
|
||||
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
|
||||
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
|
||||
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
|
||||
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
|
||||
</sectionGroup>
|
||||
</sectionGroup>
|
||||
</sectionGroup>
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
||||
<sectionGroup name="system.web">
|
||||
<section name="membership" type="System.Web.Configuration.MembershipSection, System.Web" />
|
||||
<section name="blog" type="Yavsc.Model.DataProviderConfigurationSection, YavscModel" allowLocation="true" requirePermission="false" allowDefinition="Everywhere" />
|
||||
<section name="thanks" type="Yavsc.ThanksConfigurationSection, Yavsc" allowLocation="true" requirePermission="false" allowDefinition="Everywhere" />
|
||||
<section name="catalog" type="Yavsc.Model.FrontOffice.Configuration.CatalogProvidersConfigurationSection, YavscModel" allowLocation="true" requirePermission="false" allowDefinition="Everywhere" />
|
||||
<section name="workflow" type="Yavsc.Model.DataProviderConfigurationSection, YavscModel" allowLocation="true" requirePermission="false" allowDefinition="Everywhere" />
|
||||
<section name="circleProviders" type="Yavsc.Model.DataProviderConfigurationSection, YavscModel" />
|
||||
<section name="userNameManager" type="Yavsc.Model.DataProviderConfigurationSection, YavscModel" />
|
||||
</sectionGroup>
|
||||
<section name="paypal" type="PayPal.SDKConfigHandler, PayPal" />
|
||||
</configSections>
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql" />
|
||||
</DbProviderFactories>
|
||||
</system.data>
|
||||
<system.web>
|
||||
<authentication mode="Forms" >
|
||||
<forms loginUrl="login.aspx"
|
||||
name=".ASPXFORMSAUTH" />
|
||||
</authentication>
|
||||
<authorization>
|
||||
<deny users="?" />
|
||||
</authorization>
|
||||
<membership defaultProvider="NpgsqlMembershipProvider" userIsOnlineTimeWindow="1">
|
||||
<providers>
|
||||
<clear />
|
||||
<add name="NpgsqlMembershipProvider" type="Npgsql.Web.NpgsqlMembershipProvider, NpgsqlMRPProviders"
|
||||
connectionStringName="yavsc" enablePasswordRetrieval="false"
|
||||
enablePasswordReset="true" requiresQuestionAndAnswer="false"
|
||||
requiresUniqueEmail="true" passwordFormat="Clear" maxInvalidPasswordAttempts="5"
|
||||
minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"
|
||||
passwordAttemptWindow="10" applicationName="/" autogenerateschema="false" />
|
||||
</providers>
|
||||
</membership>
|
||||
<roleManager enabled="true" defaultProvider="NpgsqlRoleProvider">
|
||||
<providers>
|
||||
<clear />
|
||||
<add name="NpgsqlRoleProvider" connectionStringName="yavsc" applicationName="/" type="Npgsql.Web.NpgsqlRoleProvider, NpgsqlMRPProviders" autogenerateschema="false" />
|
||||
</providers>
|
||||
</roleManager>
|
||||
<userNameManager defaultProvider="NpsqlUserNameProvider">
|
||||
<providers>
|
||||
<add name="NpsqlUserNameProvider" connectionStringName="yavsc" applicationName="/" type="Npgsql.Web.RolesAndMembers.NpgsqlUserNameProvider, NpgsqlMRPProviders" autogenerateschema="false">
|
||||
</add>
|
||||
</providers>
|
||||
</userNameManager>
|
||||
<workflow defaultProvider="ITProvider">
|
||||
<providers>
|
||||
<clear />
|
||||
<add name="ITProvider" type="Yavsc.ITCPNpgsqlProvider, ITContentProvider" applicationName="/" connectionStringName="yavsc" />
|
||||
</providers>
|
||||
</workflow>
|
||||
<profile defaultProvider="NpgsqlProfileProvider">
|
||||
<providers>
|
||||
<clear />
|
||||
<add name="NpgsqlProfileProvider" type="Npgsql.Web.NpgsqlProfileProvider, NpgsqlMRPProviders" connectionStringName="yavsc" applicationName="/" description="ProfileProvider for yavsc" />
|
||||
</providers>
|
||||
<properties>
|
||||
<add name="Name" />
|
||||
<add name="Phone" />
|
||||
<add name="Mobile" />
|
||||
<add name="Avatar" />
|
||||
<add name="BlogVisible" type="System.Boolean" />
|
||||
<add name="BlogTitle" />
|
||||
<add name="WebSite" />
|
||||
<add name="Address" />
|
||||
<add name="CityAndState" />
|
||||
<add name="ZipCode" />
|
||||
<add name="Country" />
|
||||
<add name="BankCode" />
|
||||
<add name="IBAN" />
|
||||
<add name="BIC" />
|
||||
<add name="WicketCode" />
|
||||
<add name="AccountNumber" />
|
||||
<add name="BankedKey" />
|
||||
<add name="gtoken" />
|
||||
<add name="grefreshtoken" />
|
||||
<add name="gtokentype" />
|
||||
<add name="gtokenexpir" />
|
||||
<add name="gcalapi" />
|
||||
<add name="gcalid" />
|
||||
<add name="gregid" />
|
||||
</properties>
|
||||
</profile>
|
||||
<blog defaultProvider="NpgsqlBlogProvider">
|
||||
<providers>
|
||||
<add name="NpgsqlBlogProvider" connectionStringName="yavsc" applicationName="/" type="Npgsql.Web.Blog.NpgsqlBlogProvider, NpgsqlBlogProvider" />
|
||||
</providers>
|
||||
</blog>
|
||||
</system.web>
|
||||
<connectionStrings>
|
||||
<add name="yavsc" connectionString="Server=127.0.0.1;Port=5432;Database=totem;User Id=totemweb;Password=cZeoft2k5_d4;" providerName="Npgsql" />
|
||||
</connectionStrings>
|
||||
<appSettings>
|
||||
<add key="MonoServerDefaultIndexFiles" value="index.html,Index.aspx" />
|
||||
<add key="WorkflowContentProviderClass" value="yavsc.NpgsqlContentProvider" />
|
||||
<add key="SmtpServer" value="smtp.free.fr" />
|
||||
<add key="AdminEMail" value="paulschneider@free.fr" />
|
||||
<add key="OwnerEMail" value="" />
|
||||
<add key="Name" value="TOTEM PRODUCTION" />
|
||||
<add key="DefaultController" value="Home" />
|
||||
<add key="DefaultAvatar" value="/images/noavatar.png;image/png" />
|
||||
<add key="RegistrationMessage" value="/RegistrationMail.txt" />
|
||||
<!-- <add key="ClientValidationEnabled" value="true" /> -->
|
||||
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
|
||||
<add key="PayPalLogger" value="PayPal.Log.Log4netLogger" />
|
||||
</appSettings>
|
||||
</configuration>
|
||||
Loading…
Add table
Add a link
Reference in a new issue