diff options
| author | Teddy Wing | 2017-06-09 12:24:03 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-06-09 12:24:03 +0200 | 
| commit | 652c63e3d5e9f842d88ea9bc3ae027712922f69a (patch) | |
| tree | 589820f174754d65fc28523c1a7ae0b3c7a78ad1 /spec | |
| parent | 4ce4f81ed51ec5215ecef431e6ed2cbbbef0952a (diff) | |
| download | chouette-core-652c63e3d5e9f842d88ea9bc3ae027712922f69a.tar.bz2 | |
TableBuilder spec: Give test user all referential permissions
Our expected output renders edit and destroy links in the cog menu:
    @@ -35,9 +35,7 @@
                         <div class="btn dropdown-toggle" data-toggle="dropdown"><span class="fa fa-cog"></span></div>
                         <ul class="dropdown-menu">
                             <li><a href="/referentials/1008">Consulter</a></li>
    -                        <li><a href="/referentials/1008/edit">Editer</a></li>
                             <li><a rel="nofollow" data-method="put" href="/referentials/1008/archive">Conserver</a></li>
    -                        <li class="delete-action"><a data-confirm="Etes-vous sûr(e) de vouloir effectuer cette action ?" rel="nofollow" data-method="delete" href="/referentials/1008"><span class="fa fa-trash"></span>Supprimer</a></li>
                         </ul>
                     </div>
                 </td>
It does this because I copied it from HTML rendered from my local dev
server, where my normal login user has admin permissions.
The actual HTML output doesn't render those links because the
factory-generated user for the test doesn't have permissions to those
links.
To get the actual to match the expected string, give our test user the
proper permissions and ensure their organisation is the same as the test
referential's organisation (as defined by the permissions in
`ReferentialPolicy`).
Refs #3479
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/helpers/table_builder_helper_spec.rb | 10 | 
1 files changed, 9 insertions, 1 deletions
diff --git a/spec/helpers/table_builder_helper_spec.rb b/spec/helpers/table_builder_helper_spec.rb index a58905244..f3a6001d0 100644 --- a/spec/helpers/table_builder_helper_spec.rb +++ b/spec/helpers/table_builder_helper_spec.rb @@ -16,7 +16,15 @@ describe TableBuilderHelper, type: :helper do        #   referential: referential        # )        user_context = OpenStruct.new( -        user: build_stubbed(:user), +        user: build_stubbed( +          :user, +          organisation: referential.organisation, +          permissions: [ +            'referentials.create', +            'referentials.edit', +            'referentials.destroy' +          ] +        ),          context: { referential: referential }        )        allow(helper).to receive(:current_user).and_return(user_context)  | 
