diff options
| author | Zog | 2017-12-15 09:11:04 +0100 | 
|---|---|---|
| committer | Zog | 2017-12-19 14:40:38 +0100 | 
| commit | 676f45e8fd85c1422345d4d27ba2385e4bd536fe (patch) | |
| tree | e09fcebd3f7970b0043bf8adbfd5e0f54a8c73e1 /spec/views | |
| parent | 8e55e7036aafb485058bf9122bf47cde73a54c33 (diff) | |
| download | chouette-core-676f45e8fd85c1422345d4d27ba2385e4bd536fe.tar.bz2 | |
Refs #5287;
Add specs for the view.
Refactor to come
Diffstat (limited to 'spec/views')
| -rw-r--r-- | spec/views/stop_areas/index.html.erb_spec.rb | 78 | 
1 files changed, 65 insertions, 13 deletions
| diff --git a/spec/views/stop_areas/index.html.erb_spec.rb b/spec/views/stop_areas/index.html.erb_spec.rb index 2dfae1bfd..a354586d2 100644 --- a/spec/views/stop_areas/index.html.erb_spec.rb +++ b/spec/views/stop_areas/index.html.erb_spec.rb @@ -1,25 +1,77 @@  require 'spec_helper'  describe "/stop_areas/index", :type => :view do -    let!(:stop_area_referential) { assign :stop_area_referential, create(:stop_area_referential) } -  let!(:stop_areas) { assign :stop_areas, Array.new(2) { create(:stop_area, stop_area_referential: stop_area_referential) }.paginate } +  let!(:stop_areas) do +    2.times { create(:stop_area, stop_area_referential: stop_area_referential) } +    assign :stop_areas, ModelDecorator.decorate( Chouette::StopArea.page(1), with: StopAreaDecorator ) +  end    let!(:q) { assign :q, Ransack::Search.new(Chouette::StopArea) }    before :each do      allow(view).to receive(:link_with_search).and_return("#") +    allow(view).to receive(:collection).and_return(stop_areas) +    allow(view).to receive(:current_referential).and_return(stop_area_referential) +    controller.request.path_parameters[:stop_area_referential_id] = stop_area_referential.id +    render +  end + +  it "should render a row for each group" do +    stop_areas.each do |stop_area| +      expect(rendered).to have_selector("tr.stoparea-#{stop_area.id}", count: 1) +    end +  end + +  it "should render a show link for each group" do +    stop_areas.each do |stop_area| +      expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']", count: 1) +    end +  end + +  it "should render no other link for each group" do +    stop_areas.each do |stop_area| +      expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a", count: 1) +    end    end -  # it "should render a show link for each group" do -  #   render -  #   stop_areas.each do |stop_area| -  #     expect(rendered).to have_selector(".stop_area a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']", :text => stop_area.name) -  #   end -  # end -  # -  # it "should render a link to create a new group" do -  #   render -  #   expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{new_stop_area_referential_stop_area_path(stop_area_referential)}']") -  # end +  with_permission "stop_areas.create" do +    it "should render a show link for each group" do +      stop_areas.each do |stop_area| +        expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']", count: 1) +      end +    end + +    it "should render a create link for each group" do +      stop_areas.each do |stop_area| +        expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.new_stop_area_referential_stop_area_path(stop_area_referential)}']", count: 1) +      end +    end + +    it "should render no other link for each group" do +      stop_areas.each do |stop_area| +        expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a", count: 2) +      end +    end +  end + +  with_permission "stop_areas.update" do +    it "should render a show link for each group" do +      stop_areas.each do |stop_area| +        expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']", count: 1) +      end +    end + +    it "should render a edit link for each group" do +      stop_areas.each do |stop_area| +        expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a[href='#{view.edit_stop_area_referential_stop_area_path(stop_area_referential, stop_area.id)}']", count: 1) +      end +    end + +    it "should render no other link for each group" do +      stop_areas.each do |stop_area| +        expect(rendered).to have_selector("tr.stoparea-#{stop_area.id} .actions a", count: 2) +      end +    end +  end  end | 
