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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 217b8b45d967f02b6babaecf7fd500986e60438a
4
- data.tar.gz: eb12679aaa201814133d26105e21199f3e9d6684
3
+ metadata.gz: a84e6ac633aee66acccfeaf5815a3b165a788843
4
+ data.tar.gz: c8efee4c7042e2e0cdb780c81a54f121de9f696b
5
5
  SHA512:
6
- metadata.gz: 0a53d4edae2600388c547dd9bbd06fc138f1ab5f7a2963bb00d2346280fc5fa2aa698fc4876b3d3c6faf63565c242ff1059a70e5785fdeaeb56246bb5b77f150
7
- data.tar.gz: 73e4ab6646e0d83854f23d9e9bb7e542c534a1eb33a910adaca2d01a560d08d3128e8680204c5c038502e8bda31d039e9bdefb4be82d37cf8e024c88cbc6cf78
6
+ metadata.gz: 6a6c8c26ecad3cc5fa671594bed276dbfe9084ce4c3ca06a875bfbc5b896f23d5a8db7d19b25144a57bc87ee81dc4e7da80a8e4a5f8de6b88dc6f2cdafc75d73
7
+ data.tar.gz: cd169a674f57d222d0ccc7381ee03d21c952916a54c2bdb9ac63a243abe55c7ed8055d2bb151ec89e61894cf964839dfcebd255adef6c3ab290bb8a6714749cc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fraternity (0.0.3)
4
+ fraternity (0.0.4)
5
5
  lotus-model
6
6
  lotus-validations (~> 0.2.3)
7
7
  rake
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
@@ -1,3 +1,3 @@
1
1
  module Fraternity
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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
@@ -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.3
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-01-20 00:00:00.000000000 Z
11
+ date: 2015-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake