Project

General

Profile

Defect #10535 » test-10535.patch

Go MAEDA, 2020-05-19 14:11

View differences:

app/views/common/feed.atom.builder
1 1
# frozen_string_literal: true
2 2

  
3
protocol = Setting.protocol
4
host = Setting.host_name
3 5
xml.instruct!
4 6
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
5 7
  xml.title   truncate_single_line_raw(@title, 100)
6
  xml.link    "rel" => "self", "href" => url_for(:params => request.query_parameters, :only_path => false, :format => 'atom')
7
  xml.link    "rel" => "alternate", "href" => url_for(:params => request.query_parameters.merge(:format => nil, :key => nil), :only_path => false)
8
  xml.link    "rel" => "self", "href" => url_for(:params => request.query_parameters, :only_path => false, :format => 'atom', :protocol => protocol, :host => host)
9
  xml.link    "rel" => "alternate", "href" => url_for(:params => request.query_parameters.merge(:format => nil, :key => nil), :only_path => false, :protocol => protocol, :host => host)
8 10
  xml.id      home_url
9 11
  xml.icon    favicon_url
10 12
  xml.updated((@items.first ? @items.first.event_datetime : Time.now).xmlschema)
......
12 14
  xml.generator(:uri => Redmine::Info.url) { xml.text! Redmine::Info.app_name; }
13 15
  @items.each do |item|
14 16
    xml.entry do
15
      url = url_for(item.event_url(:only_path => false))
17
      url = url_for(item.event_url(:only_path => false, :protocol => protocol, :host => host))
16 18
      if @project
17 19
        xml.title truncate_single_line_raw(item.event_title, 100)
18 20
      else
test/functional/activities_controller_test.rb
106 106
  end
107 107

  
108 108
  def test_index_atom_feed
109
    get(
110
      :index,
111
      :params => {
112
        :format => 'atom',
113
        :with_subprojects => 0
114
      }
115
    )
109
    with_settings :protocol => 'http', :host_name => 'redmine.test' do
110
      get(
111
        :index,
112
        :params => {
113
          :format => 'atom',
114
          :with_subprojects => 0
115
        }
116
      )
117
    end
116 118
    assert_response :success
117 119

  
118 120
    assert_select 'feed' do
119
      assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0'
120
      assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?with_subprojects=0'
121
      assert_select 'link[rel=self][href=?]', 'http://redmine.test/activity.atom?with_subprojects=0'
122
      assert_select 'link[rel=alternate][href=?]', 'http://redmine.test/activity?with_subprojects=0'
121 123
      assert_select 'entry' do
122
        assert_select 'link[href=?]', 'http://test.host/issues/11'
124
        assert_select 'link[href=?]', 'http://redmine.test/issues/11'
123 125
      end
124 126
    end
125 127
  end
126 128

  
127 129
  def test_index_atom_feed_with_explicit_selection
128
    get(
129
      :index,
130
      :params => {
131
        :format => 'atom',
132
        :with_subprojects => 0,
133
        :show_changesets => 1,
134
        :show_documents => 1,
135
        :show_files => 1,
136
        :show_issues => 1,
137
        :show_messages => 1,
138
        :show_news => 1,
139
        :show_time_entries => 1,
140
        :show_wiki_edits => 1
141
      }
142
    )
130
    with_settings :protocol => 'https', :host_name => 'redmine.example' do
131
      get(
132
        :index,
133
        :params => {
134
          :format => 'atom',
135
          :with_subprojects => 0,
136
          :show_changesets => 1,
137
          :show_documents => 1,
138
          :show_files => 1,
139
          :show_issues => 1,
140
          :show_messages => 1,
141
          :show_news => 1,
142
          :show_time_entries => 1,
143
          :show_wiki_edits => 1
144
        }
145
      )
146
    end
143 147
    assert_response :success
144 148

  
145 149
    assert_select 'feed' do
146
      assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'
147
      assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'
150
      assert_select 'link[rel=self][href=?]', 'https://redmine.example/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'
151
      assert_select 'link[rel=alternate][href=?]', 'https://redmine.example/activity?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'
148 152
      assert_select 'entry' do
149
        assert_select 'link[href=?]', 'http://test.host/issues/11'
153
        assert_select 'link[href=?]', 'https://redmine.example/issues/11'
150 154
      end
151 155
    end
152 156
  end
test/functional/issues_controller_test.rb
1138 1138
  end
1139 1139

  
1140 1140
  def test_index_atom
1141
    get(
1142
      :index,
1143
      :params => {
1144
        :project_id => 'ecookbook',
1145
        :format => 'atom'
1146
      }
1147
    )
1141
    with_settings :protocol => 'https', :host_name => 'example.net' do
1142
      get(
1143
        :index,
1144
        :params => {
1145
          :project_id => 'ecookbook',
1146
          :format => 'atom'
1147
        }
1148
      )
1149
    end
1148 1150
    assert_response :success
1149 1151
    assert_equal 'application/atom+xml', response.media_type
1150 1152

  
1151 1153
    assert_select 'feed' do
1152
      assert_select 'link[rel=self][href=?]', 'http://test.host/projects/ecookbook/issues.atom'
1153
      assert_select 'link[rel=alternate][href=?]', 'http://test.host/projects/ecookbook/issues'
1154
      assert_select 'entry link[href=?]', 'http://test.host/issues/1'
1154
      assert_select 'link[rel=self][href=?]', 'https://example.net/projects/ecookbook/issues.atom'
1155
      assert_select 'link[rel=alternate][href=?]', 'https://example.net/projects/ecookbook/issues'
1156
      assert_select 'entry link[href=?]', 'https://example.net/issues/1'
1155 1157
    end
1156 1158
  end
1157 1159

  
(2-2/2)