aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/workbenches_spec.rb
blob: 1b38869857acbf5d3fa2ba1268ae64cd609ea224 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# coding: utf-8
require 'spec_helper'

describe 'Workbenches', type: :feature do
  login_user

  #let!(:organisations) { Array.new(2) { create :organisation } }
  #let!(:referentials) { Array.new(2) { create :referential, ready: true } }
  let(:line_referential) { create :line_referential }
  let(:workbenches) { Array.new(2) { create :workbench, line_referential: line_referential, organisation: @user.organisation } }
  let(:workbench) { workbenches.first }
  let!(:line) { create :line, line_referential: line_referential }

  let(:referential_metadatas) { Array.new(2) { |i| create :referential_metadata, lines: [line] } }

  describe 'show' do

    let!(:ready_referential) { create :referential, workbench: workbench, metadatas: referential_metadatas, ready: true, organisation: @user.organisation }
    let!(:unready_referential) { create :referential, workbench: workbench }

    it 'shows ready referentials belonging to that workbench by default' do
      visit workbench_path(workbench)
      expect(page).to have_content(ready_referential.name)
      expect(page).not_to have_content(unready_referential.name)
    end
  end

  describe 'create new Referential' do
    it "create a new Referential with a specifed line and period" do
      visit workbench_path(workbench)

      click_link "Ajouter un jeu de données"

      fill_in "referential[name]", with: "Referential to test creation" # Nom du JDD
      fill_in "referential[slug]", with: "test" # Code
      fill_in "referential[prefix]", with: "test" # Prefix Neptune
      select workbench.lines.first.id, from: 'referential[metadatas_attributes][0][lines][]' # Lignes

      click_button "Enregistrer"
      expect(page).to have_css("h1", text: "Referential to test creation")
    end
  end
end