diff options
| author | Zog | 2018-01-23 14:05:11 +0100 |
|---|---|---|
| committer | Zog | 2018-02-09 10:22:01 +0100 |
| commit | 81e6a92e128ac747f526a83efb5a88157f71635a (patch) | |
| tree | aaf6e8e943bb18723369812074006acc8101bc59 | |
| parent | f114485e22c17239f3d7be06eb3bc1abffbbfe4b (diff) | |
| download | chouette-core-81e6a92e128ac747f526a83efb5a88157f71635a.tar.bz2 | |
Refs #5669; Add more snapshots
15 files changed, 167 insertions, 33 deletions
diff --git a/spec/views/companies/__snapshots__/companies/index.snap b/spec/views/companies/__snapshots__/companies/index.snap new file mode 100644 index 000000000..2c5c23400 --- /dev/null +++ b/spec/views/companies/__snapshots__/companies/index.snap @@ -0,0 +1,4 @@ +<div class="container-fluid"><div class="row"> +<div class="col-lg-9 col-md-8 col-sm-7 col-xs-7"><div class="page-title"></div></div> +<div class="col-lg-3 col-md-4 col-sm-5 col-xs-5 text-right"><div class="page-action"></div></div> +</div></div>
\ No newline at end of file diff --git a/spec/views/companies/__snapshots__/companies/index_create.snap b/spec/views/companies/__snapshots__/companies/index_create.snap new file mode 100644 index 000000000..edf531f62 --- /dev/null +++ b/spec/views/companies/__snapshots__/companies/index_create.snap @@ -0,0 +1,4 @@ +<div class="container-fluid"><div class="row"> +<div class="col-lg-9 col-md-8 col-sm-7 col-xs-7"><div class="page-title"></div></div> +<div class="col-lg-3 col-md-4 col-sm-5 col-xs-5 text-right"><div class="page-action"><a class="btn btn-primary" href="/line_referentials/99/companies/new">Ajouter un transporteur</a></div></div> +</div></div>
\ No newline at end of file diff --git a/spec/views/companies/__snapshots__/companies/index_destroy.snap b/spec/views/companies/__snapshots__/companies/index_destroy.snap new file mode 100644 index 000000000..2c5c23400 --- /dev/null +++ b/spec/views/companies/__snapshots__/companies/index_destroy.snap @@ -0,0 +1,4 @@ +<div class="container-fluid"><div class="row"> +<div class="col-lg-9 col-md-8 col-sm-7 col-xs-7"><div class="page-title"></div></div> +<div class="col-lg-3 col-md-4 col-sm-5 col-xs-5 text-right"><div class="page-action"></div></div> +</div></div>
\ No newline at end of file diff --git a/spec/views/companies/__snapshots__/companies/index_update.snap b/spec/views/companies/__snapshots__/companies/index_update.snap new file mode 100644 index 000000000..2c5c23400 --- /dev/null +++ b/spec/views/companies/__snapshots__/companies/index_update.snap @@ -0,0 +1,4 @@ +<div class="container-fluid"><div class="row"> +<div class="col-lg-9 col-md-8 col-sm-7 col-xs-7"><div class="page-title"></div></div> +<div class="col-lg-3 col-md-4 col-sm-5 col-xs-5 text-right"><div class="page-action"></div></div> +</div></div>
\ No newline at end of file diff --git a/spec/views/companies/index.html.erb_spec.rb b/spec/views/companies/index.html.erb_spec.rb index 9db689ba6..8f3ce9ad3 100644 --- a/spec/views/companies/index.html.erb_spec.rb +++ b/spec/views/companies/index.html.erb_spec.rb @@ -3,7 +3,10 @@ require 'spec_helper' RSpec.describe "/companies/index", :type => :view do let!(:line_referential) { assign :line_referential, create(:line_referential) } - let!(:companies) { assign :companies, CompanyDecorator.decorate_collection(Array.new(2) { create(:company, line_referential: line_referential) }.paginate) } + let(:context){{referential: line_referential}} + let!(:companies) do + assign :companies, build_paginated_collection(:company, CompanyDecorator, line_referential: line_referential, context: context) + end let!(:search) { assign :q, Ransack::Search.new(Chouette::Company) } # Fixme #1795 @@ -22,4 +25,26 @@ RSpec.describe "/companies/index", :type => :view do # expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{new_line_referential_company_path(line_referential)}']") # end + before(:each) do + allow(view).to receive(:collection).and_return(companies) + allow(view).to receive(:current_referential).and_return(line_referential) + controller.request.path_parameters[:line_referential_id] = line_referential.id + end + + describe "action links" do + set_invariant "line_referential.id", "99" + + before(:each){ + render template: "companies/index", layout: "layouts/application" + } + + it { should match_actions_links_snapshot "companies/index" } + + %w(create update destroy).each do |p| + with_permission "companies.#{p}" do + it { should match_actions_links_snapshot "companies/index_#{p}" } + end + end + end + end diff --git a/spec/views/lines/__snapshots__/lines/index.snap b/spec/views/lines/__snapshots__/lines/index.snap new file mode 100644 index 000000000..2c5c23400 --- /dev/null +++ b/spec/views/lines/__snapshots__/lines/index.snap @@ -0,0 +1,4 @@ +<div class="container-fluid"><div class="row"> +<div class="col-lg-9 col-md-8 col-sm-7 col-xs-7"><div class="page-title"></div></div> +<div class="col-lg-3 col-md-4 col-sm-5 col-xs-5 text-right"><div class="page-action"></div></div> +</div></div>
\ No newline at end of file diff --git a/spec/views/lines/__snapshots__/lines/index_create.snap b/spec/views/lines/__snapshots__/lines/index_create.snap new file mode 100644 index 000000000..5c875b18a --- /dev/null +++ b/spec/views/lines/__snapshots__/lines/index_create.snap @@ -0,0 +1,4 @@ +<div class="container-fluid"><div class="row"> +<div class="col-lg-9 col-md-8 col-sm-7 col-xs-7"><div class="page-title"></div></div> +<div class="col-lg-3 col-md-4 col-sm-5 col-xs-5 text-right"><div class="page-action"><a class="btn btn-primary" href="/line_referentials/99/lines/new">Ajouter une ligne</a></div></div> +</div></div>
\ No newline at end of file diff --git a/spec/views/lines/__snapshots__/lines/index_destroy.snap b/spec/views/lines/__snapshots__/lines/index_destroy.snap new file mode 100644 index 000000000..2c5c23400 --- /dev/null +++ b/spec/views/lines/__snapshots__/lines/index_destroy.snap @@ -0,0 +1,4 @@ +<div class="container-fluid"><div class="row"> +<div class="col-lg-9 col-md-8 col-sm-7 col-xs-7"><div class="page-title"></div></div> +<div class="col-lg-3 col-md-4 col-sm-5 col-xs-5 text-right"><div class="page-action"></div></div> +</div></div>
\ No newline at end of file diff --git a/spec/views/lines/__snapshots__/lines/index_update.snap b/spec/views/lines/__snapshots__/lines/index_update.snap new file mode 100644 index 000000000..2c5c23400 --- /dev/null +++ b/spec/views/lines/__snapshots__/lines/index_update.snap @@ -0,0 +1,4 @@ +<div class="container-fluid"><div class="row"> +<div class="col-lg-9 col-md-8 col-sm-7 col-xs-7"><div class="page-title"></div></div> +<div class="col-lg-3 col-md-4 col-sm-5 col-xs-5 text-right"><div class="page-action"></div></div> +</div></div>
\ No newline at end of file diff --git a/spec/views/lines/__snapshots__/lines/show.snap b/spec/views/lines/__snapshots__/lines/show.snap new file mode 100644 index 000000000..c66e8ee2b --- /dev/null +++ b/spec/views/lines/__snapshots__/lines/show.snap @@ -0,0 +1,9 @@ +<div class="container-fluid"> +<div class="row"> +<div class="col-lg-9 col-md-8 col-sm-7 col-xs-7"><div class="page-title"><h1><span class="translation_missing" title="translation missing: fr.lines.title">Title</span></h1></div></div> +<div class="col-lg-3 col-md-4 col-sm-5 col-xs-5 text-right"><div class="page-action"><div class="small last-update">Dernière mise à jour le 23/01/2018 <br> Par web service</div></div></div> +</div> +<div class="row"><div class="col-lg-12 text-right mb-sm"> +<a class="btn btn-primary " href="/line_referentials/99/networks/99">Voir le réseau</a><a class="btn btn-primary " href="/line_referentials/99/companies/99">Voir le transporteur principal</a> +</div></div> +</div>
\ No newline at end of file diff --git a/spec/views/lines/__snapshots__/lines/show_create.snap b/spec/views/lines/__snapshots__/lines/show_create.snap new file mode 100644 index 000000000..c8c1f81e2 --- /dev/null +++ b/spec/views/lines/__snapshots__/lines/show_create.snap @@ -0,0 +1,9 @@ +<div class="container-fluid"> +<div class="row"> +<div class="col-lg-9 col-md-8 col-sm-7 col-xs-7"><div class="page-title"><h1><span class="translation_missing" title="translation missing: fr.lines.title">Title</span></h1></div></div> +<div class="col-lg-3 col-md-4 col-sm-5 col-xs-5 text-right"><div class="page-action"><div class="small last-update">Dernière mise à jour le 23/01/2018 <br> Par web service</div></div></div> +</div> +<div class="row"><div class="col-lg-12 text-right mb-sm"> +<a class="btn btn-primary " href="/line_referentials/99/networks/99">Voir le réseau</a><a class="btn btn-primary " href="/line_referentials/99/companies/99">Voir le transporteur principal</a><a class="btn btn-primary " href="/line_referentials/99/lines/2/edit">Editer cette ligne</a><a class="btn btn-primary " href="/line_referentials/99/lines/new">Ajouter une ligne</a> +</div></div> +</div>
\ No newline at end of file diff --git a/spec/views/lines/__snapshots__/lines/show_destroy.snap b/spec/views/lines/__snapshots__/lines/show_destroy.snap new file mode 100644 index 000000000..040a6d994 --- /dev/null +++ b/spec/views/lines/__snapshots__/lines/show_destroy.snap @@ -0,0 +1,9 @@ +<div class="container-fluid"> +<div class="row"> +<div class="col-lg-9 col-md-8 col-sm-7 col-xs-7"><div class="page-title"><h1><span class="translation_missing" title="translation missing: fr.lines.title">Title</span></h1></div></div> +<div class="col-lg-3 col-md-4 col-sm-5 col-xs-5 text-right"><div class="page-action"><div class="small last-update">Dernière mise à jour le 23/01/2018 <br> Par web service</div></div></div> +</div> +<div class="row"><div class="col-lg-12 text-right mb-sm"> +<a class="btn btn-primary " href="/line_referentials/99/networks/99">Voir le réseau</a><a class="btn btn-primary " href="/line_referentials/99/companies/99">Voir le transporteur principal</a><a data-confirm="Etes vous sûr de supprimer cette ligne ?" class="btn btn-primary " rel="nofollow" data-method="delete" href="/line_referentials/99/lines/4"><span class="fa fa-trash mr-xs"></span>Supprimer cette ligne</a> +</div></div> +</div>
\ No newline at end of file diff --git a/spec/views/lines/__snapshots__/lines/show_update.snap b/spec/views/lines/__snapshots__/lines/show_update.snap new file mode 100644 index 000000000..c66e8ee2b --- /dev/null +++ b/spec/views/lines/__snapshots__/lines/show_update.snap @@ -0,0 +1,9 @@ +<div class="container-fluid"> +<div class="row"> +<div class="col-lg-9 col-md-8 col-sm-7 col-xs-7"><div class="page-title"><h1><span class="translation_missing" title="translation missing: fr.lines.title">Title</span></h1></div></div> +<div class="col-lg-3 col-md-4 col-sm-5 col-xs-5 text-right"><div class="page-action"><div class="small last-update">Dernière mise à jour le 23/01/2018 <br> Par web service</div></div></div> +</div> +<div class="row"><div class="col-lg-12 text-right mb-sm"> +<a class="btn btn-primary " href="/line_referentials/99/networks/99">Voir le réseau</a><a class="btn btn-primary " href="/line_referentials/99/companies/99">Voir le transporteur principal</a> +</div></div> +</div>
\ No newline at end of file diff --git a/spec/views/lines/index.html.slim_spec.rb b/spec/views/lines/index.html.slim_spec.rb index fb436c545..df3622e1a 100644 --- a/spec/views/lines/index.html.slim_spec.rb +++ b/spec/views/lines/index.html.slim_spec.rb @@ -13,7 +13,7 @@ describe "/lines/index", :type => :view do let(:lines) do assign :lines, build_paginated_collection(:line, LineDecorator, line_referential: line_referential, context: context) end - let!(:q) { assign :q, Ransack::Search.new(Chouette::Line) } + let!(:q) { assign :q, Ransack::Search.new(Chouette::Line) } before :each do deactivated_line @@ -25,49 +25,69 @@ describe "/lines/index", :type => :view do render end - common_items = ->{ - it { should have_link_for_each_item(lines, "show", -> (line){ view.line_referential_line_path(line_referential, line) }) } - it { should have_link_for_each_item(lines, "network", -> (line){ view.line_referential_network_path(line_referential, line.network) }) } - it { should have_link_for_each_item(lines, "company", -> (line){ view.line_referential_company_path(line_referential, line.company) }) } - } + describe "action links" do + set_invariant "line_referential.id", "99" - common_items.call() - it { should have_the_right_number_of_links(lines, 3) } + before(:each){ + render template: "lines/index", layout: "layouts/application" + } - with_permission "lines.change_status" do - common_items.call() - it { should have_link_for_each_item(lines, "deactivate", -> (line){ view.deactivate_line_referential_line_path(line_referential, line) }) } - it { should have_the_right_number_of_links(lines, 4) } + it { should match_actions_links_snapshot "lines/index" } + + %w(create update destroy).each do |p| + with_permission "lines.#{p}" do + it { should match_actions_links_snapshot "lines/index_#{p}" } + end + end end - with_permission "lines.destroy" do - common_items.call() - it { - should have_link_for_each_item(lines, "destroy", { - href: ->(line){ view.line_referential_line_path(line_referential, line)}, - method: :delete - }) + context "links" do + before(:each){ render } + + common_items = ->{ + it { should have_link_for_each_item(lines, "show", -> (line){ view.line_referential_line_path(line_referential, line) }) } + it { should have_link_for_each_item(lines, "network", -> (line){ view.line_referential_network_path(line_referential, line.network) }) } + it { should have_link_for_each_item(lines, "company", -> (line){ view.line_referential_company_path(line_referential, line.company) }) } } - it { should have_the_right_number_of_links(lines, 4) } - end - context "with a deactivated item" do + common_items.call() + it { should have_the_right_number_of_links(lines, 3) } + with_permission "lines.change_status" do - let(:deactivated_line){ create :line, deactivated: true } + common_items.call() + it { should have_link_for_each_item(lines, "deactivate", -> (line){ view.deactivate_line_referential_line_path(line_referential, line) }) } + it { should have_the_right_number_of_links(lines, 4) } + end + with_permission "lines.destroy" do common_items.call() - it "should display an activate link for the deactivated one" do - lines.each do |line| - if line == deactivated_line - href = view.activate_line_referential_line_path(line_referential, line) - else - href = view.deactivate_line_referential_line_path(line_referential, line) + it { + should have_link_for_each_item(lines, "destroy", { + href: ->(line){ view.line_referential_line_path(line_referential, line)}, + method: :delete + }) + } + it { should have_the_right_number_of_links(lines, 4) } + end + + context "with a deactivated item" do + with_permission "lines.change_status" do + let(:deactivated_line){ create :line, deactivated: true } + + common_items.call() + it "should display an activate link for the deactivated one" do + lines.each do |line| + if line == deactivated_line + href = view.activate_line_referential_line_path(line_referential, line) + else + href = view.deactivate_line_referential_line_path(line_referential, line) + end + selector = "tr.#{TableBuilderHelper.item_row_class_name(lines)}-#{line.id} .actions a[href='#{href}']" + expect(rendered).to have_selector(selector, count: 1) end - selector = "tr.#{TableBuilderHelper.item_row_class_name(lines)}-#{line.id} .actions a[href='#{href}']" - expect(rendered).to have_selector(selector, count: 1) end + it { should have_the_right_number_of_links(lines, 4) } end - it { should have_the_right_number_of_links(lines, 4) } end end end diff --git a/spec/views/lines/show.html.erb_spec.rb b/spec/views/lines/show.html.erb_spec.rb index 9649d9c8e..65ac6bdb6 100644 --- a/spec/views/lines/show.html.erb_spec.rb +++ b/spec/views/lines/show.html.erb_spec.rb @@ -16,5 +16,26 @@ describe "/lines/show", :type => :view do before do allow(view).to receive_messages(current_organisation: referential.organisation) + controller.request.path_parameters[:line_referential_id] = line_referential.id + controller.request.path_parameters[:id] = line.id + end + + describe "action links" do + set_invariant "line_referential.id", "99" + set_invariant "line.id", "99" + set_invariant "line.company.id", "99" + set_invariant "line.network.id", "99" + + before(:each){ + render template: "lines/show", layout: "layouts/application" + } + + it { should match_actions_links_snapshot "lines/show" } + + %w(create update destroy).each do |p| + with_permission "lines.#{p}" do + it { should match_actions_links_snapshot "lines/show_#{p}" } + end + end end end |
