Exemplo n.º 1
0
        public void RepoAdminCannotRemoveThemselves()
        {
            var user = ITH.CreateUsers().Single();

            var repoId = ITH.CreateRepositoryOnWebInterface(ITH.MakeName());

            app.NavigateTo <RepositoryController>(c => c.Edit(repoId));
            var form = app.FindFormFor <RepositoryDetailModel>();

            // Set User0 to be admin for this repo
            var adminBox =
                form.WebApp.Browser.FindElementsByCssSelector(
                    string.Format("input[name=PostedSelectedAdministrators][value=\"{0}\"]", user.Id)).Single();

            ITH.SetCheckbox(adminBox, true);
            form.Submit();
            ITH.AssertThatNoValidationErrorOccurred();

            // Now, log in as the ordinary user
            ITH.LoginAsUser(user);

            app.NavigateTo <RepositoryController>(c => c.Edit(repoId));
            form = app.FindFormFor <RepositoryDetailModel>();

            var chkboxes = form.WebApp.Browser.FindElementsByCssSelector("input[name=PostedSelectedAdministrators]");

            ITH.SetCheckboxes(chkboxes, false);

            form.Submit();
            app.WaitForElementToBeVisible(By.CssSelector("div.validation-summary-errors"), TimeSpan.FromSeconds(1));
            ITH.AssertThatValidationErrorContains(Resources.Repository_Edit_CantRemoveYourself);
        }
Exemplo n.º 2
0
        public void RepoNameEnsureDuplicationDetectionStillAllowsEditOtherProperties()
        {
            var reponame = ITH.MakeName();
            var repo     = ITH.CreateRepositoryOnWebInterface(reponame);

            app.NavigateTo <RepositoryController>(c => c.Edit(repo));
            app.FindFormFor <RepositoryDetailModel>()
            .Field(f => f.Description).SetValueTo(reponame + "_other")
            .Submit();
            ITH.AssertThatNoValidationErrorOccurred();

            app.NavigateTo <RepositoryController>(c => c.Edit(repo)); // force refresh
            app.FindFormFor <RepositoryDetailModel>()
            .Field(f => f.Description).ValueShouldEqual(reponame + "_other");
        }
Exemplo n.º 3
0
        public void RepositoryCanBeSavedBySysAdminWithoutHavingAnyRepoAdmins()
        {
            var repoId = ITH.CreateRepositoryOnWebInterface(ITH.MakeName());

            app.NavigateTo <RepositoryController>(c => c.Edit(repoId));
            var form = app.FindFormFor <RepositoryDetailModel>();

            // Turn off all the admin checkboxes and save the form
            var chkboxes = form.WebApp.Browser.FindElementsByCssSelector("input[name=PostedSelectedAdministrators]");

            ITH.SetCheckboxes(chkboxes, false);

            form.Submit();
            ITH.AssertThatNoValidationErrorOccurred();
        }