diff options
| author | Teddy Wing | 2017-06-09 11:31:35 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-06-09 11:31:35 +0200 | 
| commit | 5d3cab81d61e5fb809a07f0e5fdaf00aa2f3210a (patch) | |
| tree | ca46cbc44fc5a3a0e55d6a9b8301da923f0e58e4 /spec | |
| parent | 9dab28fef1ac66b02a1ef62fdfb86cfc5ff13b96 (diff) | |
| download | chouette-core-5d3cab81d61e5fb809a07f0e5fdaf00aa2f3210a.tar.bz2 | |
TableBuilder spec: Correct expected column header hrefs
Use the correct workbench ID in the expected links for column sorting.
Previously I had copied this from rendered HTML on my local dev server.
We should actually use the ID of the factory-generated workbench object.
Now this part of our tests passes, correctly matching the URLs.
Needed to copy over the `q` params that are created by the
`WorkbenchesController` in order for this to actually work with the
right query string parameters tacked on to the hrefs. Makes the test a
bit more complicated, but more closely matches the real page's
behaviour.
Hrm, I wonder if we should get rid of that param entirely and
modify the expected hrefs to removed them since that doesn't really
appear to be related to what we're actually testing. I'll consider it.
Refs #3479
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/helpers/table_builder_helper_spec.rb | 25 | 
1 files changed, 16 insertions, 9 deletions
diff --git a/spec/helpers/table_builder_helper_spec.rb b/spec/helpers/table_builder_helper_spec.rb index 1049bf996..6f3ca7ee3 100644 --- a/spec/helpers/table_builder_helper_spec.rb +++ b/spec/helpers/table_builder_helper_spec.rb @@ -9,6 +9,7 @@ describe TableBuilderHelper, type: :helper do    describe "#table_builder_2" do      it "builds a table" do        referential = build_stubbed(:referential) +      workbench = referential.workbench        # user_context = create_user_context(        #   user: build_stubbed(:user), @@ -27,7 +28,13 @@ describe TableBuilderHelper, type: :helper do        allow(helper).to receive(:params).and_return({          controller: 'workbenches',          action: 'show', -        id: referentials[0].workbench.id +        id: referentials[0].workbench.id, + +        # These are added by WorkbenchesController#query_params +        q: { +          archived_at_not_null: 1, +          archived_at_null: 1 +        }        })        expected = <<-HTML @@ -37,14 +44,14 @@ describe TableBuilderHelper, type: :helper do              <th>                  <div class="checkbox"><input type="checkbox" name="0" id="0" value="all" /><label for="0"></label></div>              </th> -            <th><a href="/workbenches/1?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=name">Nom<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> -            <th><a href="/workbenches/1?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=status">Etat<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> -            <th><a href="/workbenches/1?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=organisation">Organisation<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> -            <th><a href="/workbenches/1?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=validity_period">Période de validité englobante<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> -            <th><a href="/workbenches/1?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=lines">Lignes<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> -            <th><a href="/workbenches/1?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=created_at">Créé le<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> -            <th><a href="/workbenches/1?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=updated_at">Edité le<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> -            <th><a href="/workbenches/1?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=published_at">Intégré le<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> +            <th><a href="/workbenches/#{workbench.id}?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=name">Nom<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> +            <th><a href="/workbenches/#{workbench.id}?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=status">Etat<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> +            <th><a href="/workbenches/#{workbench.id}?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=organisation">Organisation<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> +            <th><a href="/workbenches/#{workbench.id}?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=validity_period">Période de validité englobante<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> +            <th><a href="/workbenches/#{workbench.id}?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=lines">Lignes<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> +            <th><a href="/workbenches/#{workbench.id}?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=created_at">Créé le<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> +            <th><a href="/workbenches/#{workbench.id}?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=updated_at">Edité le<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th> +            <th><a href="/workbenches/#{workbench.id}?direction=desc&q%5Barchived_at_not_null%5D=1&q%5Barchived_at_null%5D=1&sort=published_at">Intégré le<span class="orderers"><span class="fa fa-sort-asc active"></span><span class="fa fa-sort-desc "></span></span></a></th>              <th></th>          </tr>      </thead>  | 
