genkan 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/Rakefile +11 -11
- data/app/controllers/concerns/genkan/authenticatable.rb +16 -16
- data/app/controllers/concerns/genkan/helper.rb +2 -1
- data/app/controllers/genkan/sessions_controller.rb +27 -26
- data/app/models/concerns/genkan/auth.rb +13 -13
- data/lib/generators/genkan/helper.rb +48 -48
- data/lib/generators/genkan/templates/initializer.erb +4 -3
- data/lib/genkan/config.rb +1 -1
- data/lib/genkan/engine.rb +1 -1
- data/lib/genkan/version.rb +1 -1
- data/spec/controllers/genkan/sessions_controller_spec.rb +14 -14
- data/spec/controllers/welcome_controller_spec.rb +4 -4
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/mailers/application_mailer.rb +2 -2
- data/spec/dummy/bin/bundle +2 -2
- data/spec/dummy/bin/rails +3 -3
- data/spec/dummy/bin/rake +2 -2
- data/spec/dummy/bin/setup +9 -10
- data/spec/dummy/bin/update +9 -9
- data/spec/dummy/bin/yarn +1 -1
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/config/application.rb +2 -3
- data/spec/dummy/config/boot.rb +3 -3
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/development.rb +2 -2
- data/spec/dummy/config/environments/production.rb +2 -2
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/assets.rb +2 -2
- data/spec/dummy/config/initializers/genkan.rb +5 -5
- data/spec/dummy/config/routes.rb +2 -2
- data/spec/dummy/config/spring.rb +2 -2
- data/spec/dummy/db/schema.rb +1 -3
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +1029 -0
- data/spec/lib/genkan/config_spec.rb +15 -15
- data/spec/lib/genkan_spec.rb +4 -4
- data/spec/models/user_spec.rb +47 -46
- data/spec/rails_helper.rb +7 -7
- metadata +2 -2
@@ -1,58 +1,58 @@
|
|
1
|
-
require
|
1
|
+
require "rails_helper"
|
2
2
|
|
3
3
|
RSpec.describe Genkan::Config do
|
4
4
|
let(:config) { described_class.new }
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe "initialize" do
|
7
7
|
it { expect(config.user_class_name).to eq "User" }
|
8
8
|
it { expect(config.auto_acceptance).to eq false }
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe "#user_class" do
|
12
12
|
before { config.user_class_name = user_class_name }
|
13
13
|
subject { config.user_class }
|
14
14
|
|
15
|
-
context
|
15
|
+
context "user_class_name exist" do
|
16
16
|
let(:user_class_name) { "User" }
|
17
|
-
it(
|
17
|
+
it("returns constant") { is_expected.to be User }
|
18
18
|
end
|
19
19
|
|
20
|
-
context
|
20
|
+
context "user_class_name unexist" do
|
21
21
|
let(:user_class_name) { "Anonymous" }
|
22
22
|
it { is_expected.to be_nil }
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
26
|
+
describe "#current_user_method_name" do
|
27
27
|
before { config.user_class_name = user_class_name }
|
28
28
|
subject { config.current_user_method_name }
|
29
29
|
|
30
|
-
context
|
30
|
+
context "without namespace" do
|
31
31
|
let(:user_class_name) { "AdminUser" }
|
32
|
-
it(
|
32
|
+
it("returns correctly method name") { is_expected.to eq "current_admin_user" }
|
33
33
|
end
|
34
34
|
|
35
|
-
context
|
35
|
+
context "with namespace" do
|
36
36
|
let(:user_class_name) { "Admin::User" }
|
37
|
-
it(
|
37
|
+
it("returns correctly method name") { is_expected.to eq "current_admin_user" }
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe
|
41
|
+
describe "#auto_acceptance?" do
|
42
42
|
before { config.auto_acceptance = auto_acceptance }
|
43
43
|
subject { config.auto_acceptance? }
|
44
44
|
|
45
|
-
context
|
45
|
+
context "auto_acceptance is true" do
|
46
46
|
let(:auto_acceptance) { true }
|
47
47
|
it { is_expected.to eq true }
|
48
48
|
end
|
49
49
|
|
50
|
-
context
|
50
|
+
context "auto_acceptance is false" do
|
51
51
|
let(:auto_acceptance) { false }
|
52
52
|
it { is_expected.to eq false }
|
53
53
|
end
|
54
54
|
|
55
|
-
context
|
55
|
+
context "auto_acceptance is nil" do
|
56
56
|
let(:auto_acceptance) { nil }
|
57
57
|
it { is_expected.to eq false }
|
58
58
|
end
|
data/spec/lib/genkan_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "rails_helper"
|
2
2
|
|
3
3
|
RSpec.describe Genkan do
|
4
|
-
describe
|
4
|
+
describe ".configure" do
|
5
5
|
example do
|
6
6
|
expect {
|
7
7
|
described_class.configure do |config|
|
@@ -11,12 +11,12 @@ RSpec.describe Genkan do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
describe
|
14
|
+
describe ".config" do
|
15
15
|
subject { described_class.config }
|
16
16
|
it { is_expected.to be_an_instance_of Genkan::Config }
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
19
|
+
describe "version" do
|
20
20
|
subject { described_class::VERSION }
|
21
21
|
it { is_expected.to be_a String }
|
22
22
|
end
|
data/spec/models/user_spec.rb
CHANGED
@@ -1,94 +1,94 @@
|
|
1
|
-
require
|
1
|
+
require "rails_helper"
|
2
2
|
|
3
3
|
RSpec.describe User do
|
4
|
-
it
|
4
|
+
it "has a valid factory" do
|
5
5
|
expect(build(:user)).to be_valid
|
6
6
|
end
|
7
7
|
|
8
|
-
describe
|
8
|
+
describe "scope" do
|
9
9
|
let!(:accepted) { create :user, :accepted }
|
10
10
|
let!(:not_accepted) { create :user, :not_accepted }
|
11
11
|
let!(:banned) { create :user, :banned }
|
12
12
|
let!(:not_banned) { create :user, :not_banned }
|
13
13
|
let!(:active) { create :user, :active }
|
14
14
|
|
15
|
-
describe
|
15
|
+
describe ".accepted" do
|
16
16
|
subject { described_class.accepted }
|
17
17
|
|
18
|
-
it(
|
19
|
-
it(
|
20
|
-
it(
|
18
|
+
it("includes accepted") { is_expected.to include accepted }
|
19
|
+
it("includes active") { is_expected.to include active }
|
20
|
+
it("does not include not_accepted") { is_expected.not_to include not_accepted }
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
23
|
+
describe ".not_banned" do
|
24
24
|
subject { described_class.not_banned }
|
25
25
|
|
26
|
-
it(
|
27
|
-
it(
|
28
|
-
it(
|
26
|
+
it("includes not_banned") { is_expected.to include not_banned }
|
27
|
+
it("includes active") { is_expected.to include active }
|
28
|
+
it("does not include banned") { is_expected.not_to include banned }
|
29
29
|
end
|
30
30
|
|
31
|
-
describe
|
31
|
+
describe ".active" do
|
32
32
|
subject { described_class.active }
|
33
33
|
|
34
|
-
it(
|
35
|
-
it(
|
36
|
-
it(
|
34
|
+
it("includes active") { is_expected.to include active }
|
35
|
+
it("does not include not_accepted") { is_expected.not_to include not_accepted }
|
36
|
+
it("does not include not_banned") { is_expected.not_to include not_banned }
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
describe
|
41
|
-
describe
|
40
|
+
describe "validation" do
|
41
|
+
describe "email" do
|
42
42
|
before { create :user }
|
43
43
|
|
44
44
|
it { is_expected.to validate_presence_of(:email) }
|
45
45
|
it { is_expected.to validate_uniqueness_of(:email) }
|
46
46
|
end
|
47
47
|
|
48
|
-
describe
|
48
|
+
describe "#ensure_record_has_accepted" do
|
49
49
|
before { model.valid?(:login) }
|
50
50
|
|
51
51
|
subject { model.errors.full_messages }
|
52
52
|
|
53
|
-
context
|
53
|
+
context "with accepted" do
|
54
54
|
let(:model) { build :user, :accepted }
|
55
|
-
it { is_expected.not_to include I18n.t(
|
55
|
+
it { is_expected.not_to include I18n.t("errors.messages.not_accepted") }
|
56
56
|
end
|
57
57
|
|
58
|
-
context
|
58
|
+
context "with not_accepted" do
|
59
59
|
let(:model) { build :user, :not_accepted }
|
60
|
-
it { is_expected.to include I18n.t(
|
60
|
+
it { is_expected.to include I18n.t("errors.messages.not_accepted") }
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
describe
|
64
|
+
describe "#ensure_record_has_not_banned" do
|
65
65
|
before { model.valid?(:login) }
|
66
66
|
|
67
67
|
subject { model.errors.full_messages }
|
68
68
|
|
69
|
-
context
|
69
|
+
context "with not_banned" do
|
70
70
|
let(:model) { build :user, :not_banned }
|
71
|
-
it { is_expected.not_to include I18n.t(
|
71
|
+
it { is_expected.not_to include I18n.t("errors.messages.banned") }
|
72
72
|
end
|
73
73
|
|
74
|
-
context
|
74
|
+
context "with banned" do
|
75
75
|
let(:model) { build :user, :banned }
|
76
|
-
it { is_expected.to include I18n.t(
|
76
|
+
it { is_expected.to include I18n.t("errors.messages.banned") }
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
describe
|
81
|
+
describe "callback" do
|
82
82
|
let(:user) { build(:user) }
|
83
83
|
|
84
|
-
it
|
84
|
+
it "set remember_token before create" do
|
85
85
|
expect(user.remember_token).to be_blank
|
86
86
|
user.save!
|
87
87
|
expect(user.remember_token).to be_present
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
describe
|
91
|
+
describe "#login!" do
|
92
92
|
let(:logged_in_count) { rand(1..20) }
|
93
93
|
let(:user) { build :user, logged_in_count: logged_in_count }
|
94
94
|
|
@@ -99,44 +99,45 @@ RSpec.describe User do
|
|
99
99
|
user.login!
|
100
100
|
end
|
101
101
|
|
102
|
-
context
|
102
|
+
context "when auto_acceptance is true" do
|
103
103
|
let(:auto_acceptance) { true }
|
104
104
|
|
105
105
|
before { execute }
|
106
106
|
|
107
|
-
it
|
107
|
+
it "stores last_logged_in_at" do
|
108
108
|
expect(user.last_logged_in_at).to be_present
|
109
109
|
end
|
110
110
|
|
111
|
-
it
|
112
|
-
|
111
|
+
it "increments loggin_in_count" do
|
112
|
+
result = logged_in_count + 1
|
113
|
+
expect(user.logged_in_count).to eq result
|
113
114
|
end
|
114
115
|
end
|
115
116
|
|
116
|
-
context
|
117
|
+
context "when auto_acceptance is false" do
|
117
118
|
let(:auto_acceptance) { false }
|
118
119
|
|
119
|
-
it
|
120
|
+
it "raise error ActiveRecord::RecordInvalid" do
|
120
121
|
expect { execute }.to raise_error(ActiveRecord::RecordInvalid)
|
121
122
|
end
|
122
123
|
end
|
123
124
|
end
|
124
125
|
|
125
|
-
describe
|
126
|
+
describe "#accepted?" do
|
126
127
|
subject { user.accepted? }
|
127
128
|
|
128
|
-
context
|
129
|
+
context "with accepted" do
|
129
130
|
let(:user) { build :user, :accepted }
|
130
131
|
it { is_expected.to eq true }
|
131
132
|
end
|
132
133
|
|
133
|
-
context
|
134
|
+
context "with not_accepted" do
|
134
135
|
let(:user) { build :user, :not_accepted }
|
135
136
|
it { is_expected.to eq false }
|
136
137
|
end
|
137
138
|
end
|
138
139
|
|
139
|
-
describe
|
140
|
+
describe "#accept" do
|
140
141
|
let(:user) { build :user }
|
141
142
|
|
142
143
|
subject { user.tap(&:accept) }
|
@@ -144,7 +145,7 @@ RSpec.describe User do
|
|
144
145
|
it { is_expected.to be_accepted }
|
145
146
|
end
|
146
147
|
|
147
|
-
describe
|
148
|
+
describe "#accept!" do
|
148
149
|
let(:user) { build :user }
|
149
150
|
|
150
151
|
subject { user.tap(&:accept!) }
|
@@ -153,21 +154,21 @@ RSpec.describe User do
|
|
153
154
|
it { is_expected.to be_persisted }
|
154
155
|
end
|
155
156
|
|
156
|
-
describe
|
157
|
+
describe "#banned?" do
|
157
158
|
subject { user.banned? }
|
158
159
|
|
159
|
-
context
|
160
|
+
context "with banned" do
|
160
161
|
let(:user) { build :user, :banned }
|
161
162
|
it { is_expected.to eq true }
|
162
163
|
end
|
163
164
|
|
164
|
-
context
|
165
|
+
context "with not_banned" do
|
165
166
|
let(:user) { build :user, :not_banned }
|
166
167
|
it { is_expected.to eq false }
|
167
168
|
end
|
168
169
|
end
|
169
170
|
|
170
|
-
describe
|
171
|
+
describe "#ban" do
|
171
172
|
let(:user) { build :user }
|
172
173
|
|
173
174
|
subject { user.tap(&:ban) }
|
@@ -175,7 +176,7 @@ RSpec.describe User do
|
|
175
176
|
it { is_expected.to be_banned }
|
176
177
|
end
|
177
178
|
|
178
|
-
describe
|
179
|
+
describe "#ban!" do
|
179
180
|
let(:user) { build :user }
|
180
181
|
|
181
182
|
subject { user.tap(&:ban!) }
|
data/spec/rails_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
ENV[
|
3
|
-
require File.expand_path(
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
ENV["RAILS_ENV"] ||= "test"
|
3
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
4
|
+
require "rspec/rails"
|
5
|
+
require "capybara/rails"
|
6
|
+
require "capybara/rspec"
|
7
7
|
|
8
8
|
RSpec.configure do |config|
|
9
9
|
config.include FactoryGirl::Syntax::Methods
|
@@ -44,6 +44,6 @@ OmniAuth.config.test_mode = true
|
|
44
44
|
|
45
45
|
def stub_omniauth(email: Faker::Internet.email)
|
46
46
|
OmniAuth.config.mock_auth[:google] = OmniAuth::AuthHash.new(
|
47
|
-
"provider" => "google", "info" => { "email" => email }
|
47
|
+
"provider" => "google", "info" => { "email" => email },
|
48
48
|
)
|
49
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: genkan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshiyuki Hirano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|