aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/referentials_spec.rb
blob: 65f895a9c360ce6ea8dbc08ae979d9fa12c71bf4 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: utf-8 -*-
require 'spec_helper'

describe "Referentials", :type => :feature do
  login_user

  describe "index" do

    # FIXME #823
    # it "should support no referential" do
    #   visit referentials_path
    #   expect(page).to have_content("Jeux de Données")
    # end

    context "when several referentials exist" do

      def retrieve_referential_by_slug( slug)
        @user.organisation.referentials.find_by_slug(slug) ||
          create(:referential, :slug => slug, :name => slug, :organisation => @user.organisation)
      end

      let!(:referentials) { [ retrieve_referential_by_slug("aa"),
                              retrieve_referential_by_slug("bb")] }

      # FIXME #823
      # it "should show n referentials" do
      #   visit referentials_path
      #   expect(page).to have_content(referentials.first.name)
      #   expect(page).to have_content(referentials.last.name)
      # end

    end

  end

  describe "create" do

    it "should" do
      visit new_referential_path
      fill_in "Nom", :with => "Test"
      fill_in "Code", :with => "test"
      fill_in "Point haut/droite de l'emprise par défaut", :with => "0.0, 0.0"
      fill_in "Point bas/gauche de l'emprise par défaut", :with => "1.0, 1.0"
      click_button "Enregistrer"

      expect(Referential.where(:name => "Test")).not_to be_nil
      # CREATE SCHEMA
    end

  end

  describe "destroy" do
    let(:referential) {  create(:referential, :organisation => @user.organisation) }

    it "should remove referential" do
      visit referential_path(referential)
      #click_link "Supprimer"
      #expect(Referential.where(:slug => referential.slug)).to be_blank
    end

  end

end