// Copyright 2017 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package integrations import ( "net/http" "testing" "code.gitea.io/gitea/modules/setting" "github.com/stretchr/testify/assert" ) func TestSettingShowUserEmailExplore(t *testing.T) { defer prepareTestEnv(t)() showUserEmail := setting.UI.ShowUserEmail setting.UI.ShowUserEmail = true session := loginUser(t, "user2") req := NewRequest(t, "GET", "/explore/users") resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) assert.Contains(t, htmlDoc.doc.Find(".ui.user.list").Text(), "user4@example.com", ) setting.UI.ShowUserEmail = false req = NewRequest(t, "GET", "/explore/users") resp = session.MakeRequest(t, req, http.StatusOK) htmlDoc = NewHTMLParser(t, resp.Body) assert.NotContains(t, htmlDoc.doc.Find(".ui.user.list").Text(), "user4@example.com", ) setting.UI.ShowUserEmail = showUserEmail } func TestSettingShowUserEmailProfile(t *testing.T) { defer prepareTestEnv(t)() showUserEmail := setting.UI.ShowUserEmail setting.UI.ShowUserEmail = true session := loginUser(t, "user2") req := NewRequest(t, "GET", "/user2") resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) assert.Contains(t, htmlDoc.doc.Find(".user.profile").Text(), "user2@example.com", ) setting.UI.ShowUserEmail = false req = NewRequest(t, "GET", "/user2") resp = session.MakeRequest(t, req, http.StatusOK) htmlDoc = NewHTMLParser(t, resp.Body) // Should contain since this user owns the profile page assert.Contains(t, htmlDoc.doc.Find(".user.profile").Text(), "user2@example.com", ) setting.UI.ShowUserEmail = showUserEmail session = loginUser(t, "user4") req = NewRequest(t, "GET", "/user2") resp = session.MakeRequest(t, req, http.StatusOK) htmlDoc = NewHTMLParser(t, resp.Body) assert.NotContains(t, htmlDoc.doc.Find(".user.profile").Text(), "user2@example.com", ) } func TestSettingLandingPage(t *testing.T) { defer prepareTestEnv(t)() landingPage := setting.LandingPageURL setting.LandingPageURL = setting.LandingPageHome req := NewRequest(t, "GET", "/") MakeRequest(t, req, http.StatusOK) setting.LandingPageURL = setting.LandingPageExplore req = NewRequest(t, "GET", "/") resp := MakeRequest(t, req, http.StatusFound) assert.Equal(t, "/explore", resp.Header().Get("Location")) setting.LandingPageURL = setting.LandingPageOrganizations req = NewRequest(t, "GET", "/") resp = MakeRequest(t, req, http.StatusFound) assert.Equal(t, "/explore/organizations", resp.Header().Get("Location")) setting.LandingPageURL = setting.LandingPageLogin req = NewRequest(t, "GET", "/") resp = MakeRequest(t, req, http.StatusFound) assert.Equal(t, "/user/login", resp.Header().Get("Location")) setting.LandingPageURL = landingPage } ller.rb?h=3.2.0'>commitdiffstats
path: root/app/controllers/project_enumerations_controller.rb
blob: 2326eb2c48fb903445318bbf342bf2742d9927ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Redmine - project management software
# Copyright (C) 2006-2015  Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

class ProjectEnumerationsController < ApplicationController
  before_filter :find_project_by_project_id
  before_filter :authorize

  def update
    if params[:enumerations]
      saved = Project.transaction do
        params[:enumerations].each do |id, activity|
          @project.update_or_create_time_entry_activity(id, activity)
        end
      end
      if saved
        flash[:notice] = l(:notice_successful_update)
      end
    end

    redirect_to settings_project_path(@project, :tab => 'activities')
  end

  def destroy
    @project.time_entry_activities.each do |time_entry_activity|
      time_entry_activity.destroy(time_entry_activity.parent)
    end
    flash[:notice] = l(:notice_successful_update)
    redirect_to settings_project_path(@project, :tab => 'activities')
  end
end