BigW Consortium Gitlab

tree_helper_spec.rb 738 Bytes
Newer Older
1 2 3 4
require 'spec_helper'

describe TreeHelper do
  describe 'flatten_tree' do
5
    let(:project) { create(:project, :repository) }
6

7
    before do
8 9
      @repository = project.repository
      @commit = project.commit("e56497bb")
10
    end
11 12 13 14

    context "on a directory containing more than one file/directory" do
      let(:tree_item) { double(name: "files", path: "files") }

15
      it "returns the directory name" do
16
        expect(flatten_tree(tree_item)).to match('files')
17 18 19 20 21 22
      end
    end

    context "on a directory containing only one directory" do
      let(:tree_item) { double(name: "foo", path: "foo") }

23
      it "returns the flattened path" do
24
        expect(flatten_tree(tree_item)).to match('foo/bar')
25 26 27 28
      end
    end
  end
end