snippet.rb 1.03 KB
Newer Older
Douwe Maan's avatar
Douwe Maan committed
1 2
require 'spec_helper'

3
describe SnippetsController, '(JavaScript fixtures)', type: :controller do
Douwe Maan's avatar
Douwe Maan committed
4 5 6 7 8
  include JavaScriptFixturesHelpers

  let(:admin) { create(:admin) }
  let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
  let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
9
  let(:snippet) { create(:personal_snippet, title: 'snippet.md', content: '# snippet', file_name: 'snippet.md', author: admin) }
Douwe Maan's avatar
Douwe Maan committed
10 11 12 13

  render_views

  before(:all) do
14
    clean_frontend_fixtures('snippets/')
Douwe Maan's avatar
Douwe Maan committed
15 16
  end

17
  before do
Douwe Maan's avatar
Douwe Maan committed
18
    sign_in(admin)
19
    allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo'])
Douwe Maan's avatar
Douwe Maan committed
20 21
  end

22 23 24 25
  after do
    remove_repository(project)
  end

26
  it 'snippets/show.html.raw' do |example|
27 28
    create(:discussion_note_on_snippet, noteable: snippet, project: project, author: admin, note: '- [ ] Task List Item')

29
    get(:show, params: { id: snippet.to_param })
Douwe Maan's avatar
Douwe Maan committed
30 31 32 33 34

    expect(response).to be_success
    store_frontend_fixture(response, example.description)
  end
end