diff options
| author | Teddy Wing | 2017-06-15 16:31:22 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-06-15 16:36:12 +0200 |
| commit | 690428d470440c604dcac52549baca8887fcd4c3 (patch) | |
| tree | 270ffd2dee9dd3e5f978b22c44689dab301ec236 | |
| parent | 74c33fdd3aa52df6fd431a76790d7c7ab39acfe0 (diff) | |
| download | chouette-core-690428d470440c604dcac52549baca8887fcd4c3.tar.bz2 | |
TableBuilder spec: Use `UserContext`
Instead of building our context with an `OpenStruct`, use the
`UserContext` class that actually exists and represents the thing that
we want to represent.
I had copied the `OpenStruct` way of doing from
"spec/support/pundit/policies.rb" this before I found out that
`UserContext` existed.
Refs #3479
| -rw-r--r-- | spec/helpers/table_builder_helper_spec.rb | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/spec/helpers/table_builder_helper_spec.rb b/spec/helpers/table_builder_helper_spec.rb index 764e102fb..186f47413 100644 --- a/spec/helpers/table_builder_helper_spec.rb +++ b/spec/helpers/table_builder_helper_spec.rb @@ -11,12 +11,8 @@ describe TableBuilderHelper, type: :helper do referential = build_stubbed(:referential) workbench = referential.workbench - # user_context = create_user_context( - # user: build_stubbed(:user), - # referential: referential - # ) - user_context = OpenStruct.new( - user: build_stubbed( + user_context = UserContext.new( + build_stubbed( :user, organisation: referential.organisation, permissions: [ @@ -25,7 +21,7 @@ describe TableBuilderHelper, type: :helper do 'referentials.destroy' ] ), - context: { referential: referential } + referential: referential ) allow(helper).to receive(:current_user).and_return(user_context) @@ -174,8 +170,8 @@ describe TableBuilderHelper, type: :helper do line_referential: line_referential ) - user_context = OpenStruct.new( - user: build_stubbed( + user_context = UserContext.new( + build_stubbed( :user, organisation: referential.organisation, permissions: [ @@ -184,7 +180,7 @@ describe TableBuilderHelper, type: :helper do 'referentials.destroy' ] ), - context: { referential: referential } + referential: referential ) allow(helper).to receive(:current_user).and_return(user_context) allow(TableBuilderHelper::URL).to receive(:current_referential) @@ -282,8 +278,8 @@ describe TableBuilderHelper, type: :helper do line_referential: line_referential ) - user_context = OpenStruct.new( - user: build_stubbed( + user_context = UserContext.new( + build_stubbed( :user, organisation: referential.organisation, permissions: [ @@ -292,7 +288,7 @@ describe TableBuilderHelper, type: :helper do 'referentials.destroy' ] ), - context: { referential: referential } + referential: referential ) allow(helper).to receive(:current_user).and_return(user_context) allow(TableBuilderHelper::URL).to receive(:current_referential) |
