rails_apps_testing 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.textile +4 -0
- data/lib/generators/testing/configure/configure_generator.rb +5 -0
- data/lib/generators/testing/configure/templates/spec/pundit/factories/users.rb +12 -0
- data/lib/generators/testing/configure/templates/spec/pundit/features/users/user_index_spec.rb +25 -0
- data/lib/generators/testing/configure/templates/spec/pundit/policies/user_policy_spec.rb +47 -0
- data/lib/generators/testing/configure/templates/spec/pundit/support/pundit.rb +1 -0
- data/lib/rails_apps_testing/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f34df3a109df984c6095322cf87b7bc925a60519
|
4
|
+
data.tar.gz: 521c9ef1a1ecc37f8bd8fd8161fb86517ac9ae82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00de4fa73e2471f9c9fc32225dfecbdcfd7eff8ab5aec85ba4e42e584c1993dc2dd8f15e714561f695c6043ea0d9f7327928744add0c26511d973f2b3a36d844
|
7
|
+
data.tar.gz: 84ebcd5b2cc9eb0477ff424c9106b0af481483b357710875fea0403a2ba7e1def1a783c7fd5f27815f0c372fd7210e6d843a4acae88880b5d9cfe839dd4ff02c
|
data/CHANGELOG.textile
CHANGED
@@ -45,6 +45,11 @@ module Testing
|
|
45
45
|
copy_file 'spec/omniauth/controllers/sessions_controller_spec.rb', 'spec/controllers/sessions_controller_spec.rb'
|
46
46
|
copy_file 'spec/omniauth/factories/users.rb', 'spec/factories/users.rb'
|
47
47
|
copy_file 'spec/omniauth/models/user_spec.rb', 'spec/models/user_spec.rb'
|
48
|
+
when 'pundit'
|
49
|
+
copy_file 'spec/pundit/factories/users.rb', 'spec/factories/users.rb'
|
50
|
+
copy_file 'spec/pundit/features/users/user_index_spec.rb', 'spec/features/users/user_index_spec.rb'
|
51
|
+
copy_file 'spec/pundit/policies/user_policy_spec.rb', 'spec/policies/user_policy_spec.rb'
|
52
|
+
copy_file 'spec/pundit/support/pundit.rb', 'spec/support/pundit.rb'
|
48
53
|
end
|
49
54
|
end
|
50
55
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
include Warden::Test::Helpers
|
2
|
+
Warden.test_mode!
|
3
|
+
|
4
|
+
# Feature: User index page
|
5
|
+
# As a user
|
6
|
+
# I want to see a list of users
|
7
|
+
# So I can see who has registered
|
8
|
+
feature 'User index page', :devise do
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
Warden.test_reset!
|
12
|
+
end
|
13
|
+
|
14
|
+
# Scenario: User listed on index page
|
15
|
+
# Given I am signed in
|
16
|
+
# When I visit the user index page
|
17
|
+
# Then I see my own email address
|
18
|
+
scenario 'user sees own email address' do
|
19
|
+
user = FactoryGirl.create(:user, :admin)
|
20
|
+
login_as(user, scope: :user)
|
21
|
+
visit users_path
|
22
|
+
expect(page).to have_content user.email
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
describe UserPolicy do
|
2
|
+
subject { UserPolicy }
|
3
|
+
|
4
|
+
let (:current_user) { FactoryGirl.build_stubbed :user }
|
5
|
+
let (:other_user) { FactoryGirl.build_stubbed :user }
|
6
|
+
let (:admin) { FactoryGirl.build_stubbed :user, :admin }
|
7
|
+
|
8
|
+
permissions :index? do
|
9
|
+
it "denies access if not an admin" do
|
10
|
+
expect(UserPolicy).not_to permit(current_user)
|
11
|
+
end
|
12
|
+
it "allows access for an admin" do
|
13
|
+
expect(UserPolicy).to permit(admin)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
permissions :show? do
|
18
|
+
it "prevents other users from seeing your profile" do
|
19
|
+
expect(subject).not_to permit(current_user, other_user)
|
20
|
+
end
|
21
|
+
it "allows you to see your own profile" do
|
22
|
+
expect(subject).to permit(current_user, current_user)
|
23
|
+
end
|
24
|
+
it "allows an admin to see any profile" do
|
25
|
+
expect(subject).to permit(admin)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
permissions :update? do
|
30
|
+
it "prevents updates if not an admin" do
|
31
|
+
expect(subject).not_to permit(current_user)
|
32
|
+
end
|
33
|
+
it "allows an admin to make updates" do
|
34
|
+
expect(subject).to permit(admin)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
permissions :destroy? do
|
39
|
+
it "prevents deleting yourself" do
|
40
|
+
expect(subject).not_to permit(current_user, current_user)
|
41
|
+
end
|
42
|
+
it "allows an admin to delete any user" do
|
43
|
+
expect(subject).to permit(admin, other_user)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'pundit/rspec'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_apps_testing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Kehoe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -77,6 +77,10 @@ files:
|
|
77
77
|
- lib/generators/testing/configure/templates/spec/omniauth/models/user_spec.rb
|
78
78
|
- lib/generators/testing/configure/templates/spec/omniauth/support/helpers.rb
|
79
79
|
- lib/generators/testing/configure/templates/spec/omniauth/support/helpers/omniauth.rb
|
80
|
+
- lib/generators/testing/configure/templates/spec/pundit/factories/users.rb
|
81
|
+
- lib/generators/testing/configure/templates/spec/pundit/features/users/user_index_spec.rb
|
82
|
+
- lib/generators/testing/configure/templates/spec/pundit/policies/user_policy_spec.rb
|
83
|
+
- lib/generators/testing/configure/templates/spec/pundit/support/pundit.rb
|
80
84
|
- lib/rails_apps_testing.rb
|
81
85
|
- lib/rails_apps_testing/version.rb
|
82
86
|
- rails_apps_testing.gemspec
|