diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 190fb67c..431e46ea 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -94,7 +94,7 @@ def create private def project_params - params.require(:project).permit(:name, :description, :full_name, :hold_tips, tipping_policies_text_attributes: [:text]) + params.require(:project).permit(:name, :description, :full_name, :auto_tip_commits, :hold_tips, tipping_policies_text_attributes: [:text]) end def load_project diff --git a/app/models/project.rb b/app/models/project.rb index fd2d27d0..d3bb388d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -233,4 +233,15 @@ def strip_full_name self.full_name = full_name.gsub(/https?\:\/\/github.com\//, '') end end + + def auto_tip_commits + !hold_tips + end + + def auto_tip_commits=(value) + self.hold_tips = case value + when false, nil, "0" then true + else false + end + end end diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 225822fb..7878894b 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -6,6 +6,6 @@ = fields.text_area :text, rows: 10, label: "Tipping policies" = f.url_field :full_name, label: "GitHub URL (optional)" = f.form_group do - = f.check_box :hold_tips, label: "Do not send the tips immediatly. Give collaborators the ability to modify the tips before they're sent" + = f.check_box :auto_tip_commits, {label: "Automatically send 1% of the balance to each commit added to the default branch of the GitHub project"} = f.form_group do = f.primary "Save" diff --git a/features/step_definitions/web.rb b/features/step_definitions/web.rb index c26f57cc..5cd9e525 100644 --- a/features/step_definitions/web.rb +++ b/features/step_definitions/web.rb @@ -53,6 +53,10 @@ check(arg1) end +Given(/^I uncheck "(.*?)"$/) do |arg1| + uncheck(arg1) +end + Then(/^I should see "(.*?)"$/) do |arg1| page.should have_content(arg1) end diff --git a/features/tip_modifier_interface.feature b/features/tip_modifier_interface.feature index dc0f34f3..dc550ea3 100644 --- a/features/tip_modifier_interface.feature +++ b/features/tip_modifier_interface.feature @@ -23,7 +23,7 @@ Feature: A project collaborator can change the tips of commits Given I'm logged in as "seldon" And I go to the project page And I click on "Change project settings" - And I check "Do not send the tips immediatly. Give collaborators the ability to modify the tips before they're sent" + And I uncheck "Automatically send 1% of the balance to each commit added to the default branch of the GitHub project" And I click on "Save" Then I should see "The project has been updated"