hide the real name of the plain format

pull/2554/head
Jan Sandbrink 10 years ago
parent 6b3ee56936
commit dd67b3bf8e
  1. 2
      lib/api/decorators/formattable.rb
  2. 3
      lib/api/v3/render/render_api.rb
  3. 2
      lib/api/v3/utilities/path_helper.rb
  4. 2
      lib/api/v3/versions/version_representer.rb
  5. 4
      lib/open_project/text_formatting.rb
  6. 2
      spec/lib/api/decorators/formattable_spec.rb
  7. 2
      spec/lib/open_project/text_formatting_spec.rb

@ -41,7 +41,7 @@ module API
property :format,
exec_context: :decorator,
getter: -> (*) { @format == '' ? 'plain' : @format },
getter: -> (*) { @format },
writable: false,
render_nil: true
property :raw,

@ -53,7 +53,7 @@ module API
end
def check_format(format)
supported_formats = [''] # we always support no formatting (aka 'plain')
supported_formats = ['plain']
supported_formats += Array(Redmine::WikiFormatting.format_names)
unless supported_formats.include?(format)
fail ::API::Errors::NotFound, I18n.t('api_v3.errors.code_404')
@ -108,7 +108,6 @@ module API
route_param :render_format do
before do
@format = params[:render_format]
@format = '' if @format == 'plain' # 'plain' is called '' internally
end
post do

@ -92,7 +92,7 @@ module API
def self.render_markup(format: nil, link: nil)
format = format || Setting.text_formatting
format = 'plain' if format == ''
format = 'plain' if format == '' # Setting will return '' for plain
path = "#{root}/render/#{format}"
path += "?#{link}" if link

@ -56,7 +56,7 @@ module API
getter: -> (*) {
::API::Decorators::Formattable.new(represented.description,
object: represented,
format: '')
format: 'plain')
},
render_nil: true

@ -82,7 +82,9 @@ module OpenProject
project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
only_path = options.delete(:only_path) == false ? false : true
format = options[:format] || Setting.text_formatting
# offer 'plain' as readable version for 'no formatting' to callers
options_format = options[:format] == 'plain' ? '' : options[:format]
format = options_format || Setting.text_formatting
text = Redmine::WikiFormatting.to_html(format, text,
object: obj,
attribute: attr,

@ -49,7 +49,7 @@ describe ::API::Decorators::Formattable do
end
context 'format specified explicitly' do
subject { described_class.new(represented, format: '').to_json }
subject { described_class.new(represented, format: 'plain').to_json }
it 'should indicate the explicit format' do
is_expected.to be_json_eql('plain'.to_json).at_path('format')

@ -513,7 +513,7 @@ EXPECTED
end
it 'uses format of options, if specified' do
expect(format_text('*Stars!*', format: '')).to eq('<p>*Stars!*</p>')
expect(format_text('*Stars!*', format: 'plain')).to eq('<p>*Stars!*</p>')
end
end
end

Loading…
Cancel
Save