Commit 38f289cf authored by nmilojevic1's avatar nmilojevic1

Fix project export presenter

- Fix specs for #description method
- Remove as_json override, use description method
parent ebd8fabb
......@@ -3,14 +3,16 @@
module Projects
module ImportExport
class ProjectExportPresenter < Gitlab::View::Presenter::Delegated
include ActiveModel::Serializers::JSON
presents :project
def project_members
super + converted_group_members
end
def as_json(*_args)
self.respond_to?(:override_description) ? super.merge("description" => override_description) : super
def description
self.respond_to?(:override_description) ? override_description : super
end
private
......
......@@ -5,26 +5,44 @@ require 'spec_helper'
describe Projects::ImportExport::ProjectExportPresenter do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:user) { create(:user) }
let(:description) { "overridden description" }
subject { described_class.new(project, current_user: user, override_description: description) }
subject { described_class.new(project, current_user: user) }
describe '#description' do
context "override_description not provided" do
it "keeps original description" do
expect(subject.description).to eq(project.description)
end
end
describe '#as_json' do
context "override_description provided" do
let(:description) { "overridden description" }
subject { described_class.new(project, current_user: user, override_description: description) }
it "overrides description" do
expect(subject.as_json["description"]).to eq(description)
expect(subject.description).to eq(description)
end
end
end
describe '#as_json' do
context "override_description not provided" do
subject { described_class.new(project, current_user: user) }
it "keeps original description" do
expect(subject.as_json["description"]).to eq(project.description)
end
end
context "override_description provided" do
let(:description) { "overridden description" }
subject { described_class.new(project, current_user: user, override_description: description) }
it "overrides description" do
expect(subject.as_json["description"]).to eq(description)
end
end
end
describe '#project_members' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment