fraternity 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -1
- data/lib/fraternity.rb +3 -2
- data/lib/fraternity/configuration.rb +2 -1
- data/lib/fraternity/version.rb +1 -1
- data/spec/fraternity/configuration_spec.rb +5 -0
- data/spec/fraternity/pledge_spec.rb +1 -0
- data/spec/fraternity_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a84e6ac633aee66acccfeaf5815a3b165a788843
|
4
|
+
data.tar.gz: c8efee4c7042e2e0cdb780c81a54f121de9f696b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a6c8c26ecad3cc5fa671594bed276dbfe9084ce4c3ca06a875bfbc5b896f23d5a8db7d19b25144a57bc87ee81dc4e7da80a8e4a5f8de6b88dc6f2cdafc75d73
|
7
|
+
data.tar.gz: cd169a674f57d222d0ccc7381ee03d21c952916a54c2bdb9ac63a243abe55c7ed8055d2bb151ec89e61894cf964839dfcebd255adef6c3ab290bb8a6714749cc
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -68,6 +68,9 @@ Fraternity.configure do |config|
|
|
68
68
|
configure.send_invite = lambda do |pledge|
|
69
69
|
BetaMailer.invite_email(pledge).deliver
|
70
70
|
end
|
71
|
+
config.receive_pledge = lambda do |pledge|
|
72
|
+
AdminMailer.new_pledge_email(pledge).deliver
|
73
|
+
end
|
71
74
|
end
|
72
75
|
```
|
73
76
|
|
@@ -80,7 +83,7 @@ params = { email: "jeremy.piven@example.com" } # Optional attributes you want to
|
|
80
83
|
pledge = Fraternity.rush! params
|
81
84
|
```
|
82
85
|
|
83
|
-
The above saves the information to the pledges database and creates a token for a `Pledge`
|
86
|
+
The above saves the information to the pledges database and creates a token for a `Pledge`. It calls the `receive_pledge` hook with the new `Pledge` instance that is defined in the configuration.
|
84
87
|
|
85
88
|
### Moving up the initiation line
|
86
89
|
|
data/lib/fraternity.rb
CHANGED
@@ -21,12 +21,13 @@ module Fraternity
|
|
21
21
|
pledge = Repositories::PledgeRepository.find_by_email params[:email]
|
22
22
|
if pledge
|
23
23
|
pledge.merge params
|
24
|
-
pledge
|
25
24
|
else
|
26
25
|
params[:token] ||= TemporaryToken.generate_random_token
|
27
26
|
params[:initiation_number] ||= Time.now.to_i
|
28
|
-
Fraternity::Pledge.new params
|
27
|
+
pledge = Fraternity::Pledge.new params
|
29
28
|
end
|
29
|
+
configuration.receive_pledge.call pledge
|
30
|
+
pledge
|
30
31
|
end
|
31
32
|
|
32
33
|
def self.rush!(params)
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module Fraternity
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :database_url, :send_invite
|
3
|
+
attr_accessor :database_url, :send_invite, :receive_pledge
|
4
4
|
|
5
5
|
def initialize
|
6
|
+
@receive_pledge = lambda { |pledge| pledge }
|
6
7
|
@send_invite = lambda { |pledge| pledge }
|
7
8
|
end
|
8
9
|
end
|
data/lib/fraternity/version.rb
CHANGED
@@ -3,4 +3,9 @@ describe Fraternity::Configuration do
|
|
3
3
|
configuration = Fraternity::Configuration.new
|
4
4
|
expect { configuration.send_invite.call(nil) }.to_not raise_error
|
5
5
|
end
|
6
|
+
|
7
|
+
it "has a default receive_pledge proc" do
|
8
|
+
configuration = Fraternity::Configuration.new
|
9
|
+
expect { configuration.receive_pledge.call(nil) }.to_not raise_error
|
10
|
+
end
|
6
11
|
end
|
@@ -59,6 +59,7 @@ describe Fraternity::Pledge do
|
|
59
59
|
|
60
60
|
describe "#cross!" do
|
61
61
|
it "sets the date and time of when the pledge has accepted the invite to the current date and time" do
|
62
|
+
load_repositories!
|
62
63
|
token = "12345"
|
63
64
|
pledge = Fraternity::Pledge.new token: token, invited_at: DateTime.now
|
64
65
|
pledge.cross! token
|
data/spec/fraternity_spec.rb
CHANGED
@@ -51,6 +51,8 @@ describe Fraternity do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
describe ".rush" do
|
54
|
+
before { load_repositories! }
|
55
|
+
|
54
56
|
it "rushes with parameters that describe the pledge" do
|
55
57
|
expect { Fraternity.rush email: "blah" }.to_not raise_error
|
56
58
|
end
|
@@ -77,6 +79,17 @@ describe Fraternity do
|
|
77
79
|
expect((Time.now - initiated_at).to_i).to be < 1
|
78
80
|
end
|
79
81
|
|
82
|
+
it "calls the receive pledge hook" do
|
83
|
+
receive_pledge = false
|
84
|
+
Fraternity.configure(false) do |c|
|
85
|
+
c.receive_pledge = lambda do |pledge|
|
86
|
+
receive_pledge = true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
pledges = Fraternity.rush
|
90
|
+
expect(receive_pledge).to be true
|
91
|
+
end
|
92
|
+
|
80
93
|
it "uses the provided initiation number if there is one" do
|
81
94
|
pledge = Fraternity.rush initiation_number: 12345
|
82
95
|
expect(pledge.initiation_number).to eq 12345
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fraternity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Wright
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|