FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Admins can set minimum tip amount in the configuration file · tip4commit/tip4commit@b09992e · GitHub

Repository navigation

Commit b09992e

Browse files
committed
Admins can set minimum tip amount in the configuration file
1 parent 5bf2030 commit b09992e

5 files changed

Lines changed: 27 additions & 2 deletions

File tree

‎app/models/project.rb‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def tip_for commit
134134
commit: commit.sha,
135135
commit_message: commit.commit.message })
136136

137-
tip.notify_user
137+
# tip.notify_user
138138

139139
Rails.logger.info " Tip created #{tip.inspect}"
140140
end
@@ -161,7 +161,9 @@ def tips_paid_unclaimed_amount
161161
end
162162

163163
def next_tip_amount
164-
(CONFIG["tip"]*available_amount).ceil
164+
next_tip_amount = (CONFIG["tip"]*available_amount).ceil
165+
next_tip_amount = [next_tip_amount, CONFIG["min_tip"]].max if CONFIG["min_tip"]
166+
next_tip_amount = [next_tip_amount, available_amount].min
165167
end
166168

167169
def update_cache

‎config/config.yml.sample‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ smtp_settings:
3535
tip: 0.01
3636
min_payout: 100000
3737
our_fee: 0.05
38+
min_tip: 50000 # optional
3839

3940
deposit_address: 1M4bS4gPyA6Kb8w7aXsgth9oUZWcRk73tQ
4041

‎features/min_tip_amount.feature‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Feature: Admins can set minimum tip amount in the configuration file
2+
Background:
3+
Given a project "my-project"
4+
And our fee is "0"
5+
And min tip amount is "300"
6+
And a deposit of "500"
7+
And the last known commit is "COMMIT1"
8+
9+
Scenario: Developer gets more than 1% of funds, but less than available_amount
10+
And a user "yugo" has opted-in
11+
And a new commit "COMMIT2" with parent "COMMIT1"
12+
And the author of commit "COMMIT2" is "yugo"
13+
And a new commit "COMMIT3" with parent "COMMIT2"
14+
And the author of commit "COMMIT3" is "yugo"
15+
When the new commits are read
16+
Then there should be a tip of "300" for commit "COMMIT2"
17+
And there should be a tip of "200" for commit "COMMIT3"

‎features/step_definitions/common.rb‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
CONFIG["our_fee"] = arg1.to_f
2222
end
2323

24+
Given(/^min tip amount is "(.*?)"$/) do |arg1|
25+
CONFIG["min_tip"] = arg1.to_f * 1e8
26+
end
27+
2428
Given(/^a project$/) do
2529
@project = Project.create!(full_name: "example/test", github_id: 123, bitcoin_address: 'mq4NtnmQoQoPfNWEPbhSvxvncgtGo6L8WY')
2630
end

‎features/tip_modifier_interface.feature‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Feature: A project collaborator can change the tips of commits
77
| seldon |
88
| daneel |
99
And our fee is "0"
10+
And min tip amount is "0"
1011
And a deposit of "500"
1112
And the last known commit is "AAA"
1213
And a new commit "BBB" with parent "AAA"

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL