diff options
author | Fatih Acet <acetfatih@gmail.com> | 2018-02-28 03:10:43 +0300 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2018-02-28 03:10:43 +0300 |
commit | 059ab73b8eae3a546d0a19fe99ef0c52df5fac01 (patch) | |
tree | b24d4162072c0099147fcdb4f19f95511689ff6e /spec/serializers/discussion_entity_spec.rb | |
parent | 0be4a77d0012613f960c4177f53101c46de2899c (diff) |
Render MR Notes with Vue with behind a cookie
Diffstat (limited to 'spec/serializers/discussion_entity_spec.rb')
-rw-r--r-- | spec/serializers/discussion_entity_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/serializers/discussion_entity_spec.rb b/spec/serializers/discussion_entity_spec.rb new file mode 100644 index 00000000000..7ee8e38af1c --- /dev/null +++ b/spec/serializers/discussion_entity_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe DiscussionEntity do + include RepoHelpers + + let(:user) { create(:user) } + let(:note) { create(:discussion_note_on_merge_request) } + let(:discussion) { note.discussion } + let(:request) { double('request') } + let(:controller) { double('controller') } + let(:entity) { described_class.new(discussion, request: request, context: controller) } + + subject { entity.as_json } + + before do + allow(controller).to receive(:render_to_string) + allow(request).to receive(:current_user).and_return(user) + allow(request).to receive(:noteable).and_return(note.noteable) + end + + it 'exposes correct attributes' do + expect(subject).to include( + :id, :expanded, :notes, :individual_note, + :resolvable, :resolved, :resolve_path, + :resolve_with_issue_path, :diff_discussion + ) + end + + context 'when diff file is present' do + let(:note) { create(:diff_note_on_merge_request) } + + it 'exposes diff file attributes' do + expect(subject).to include(:diff_file, :truncated_diff_lines, :image_diff_html) + end + end +end |