Skip to content

Commit

Permalink
add donor strike fields to Action
Browse files Browse the repository at this point in the history
  • Loading branch information
turino committed Feb 6, 2016
1 parent d948701 commit 7cf617f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
6 changes: 4 additions & 2 deletions app/controllers/v1/actions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def activity_param
end

def action_params
params.permit(:utm_source, :utm_medium, :utm_campaign, :source_url, :donation_amount)
params.permit(:utm_source, :utm_medium, :utm_campaign, :source_url,
:donation_amount_amount_in_cents, :strike_amount_in_cents,
:privacy_status)
end

def person_params
Expand All @@ -44,4 +46,4 @@ def set_person
@person = Person.create_or_update(person_params) if person_params.present?
end

end
end
2 changes: 2 additions & 0 deletions app/models/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#

class Action < ActiveRecord::Base
enum privacy_status: [:visible, :hidden]

belongs_to :person, required: true
belongs_to :activity, required: true
belongs_to :donation_page
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddDonorStrikeFieldsToActions < ActiveRecord::Migration
def change
add_column :actions, :strike_amount_in_cents, :integer
add_column :actions, :privacy_status, :integer, default: 0
add_index :actions, :privacy_status
end
end
13 changes: 8 additions & 5 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,34 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160108175016) do
ActiveRecord::Schema.define(version: 20160206214623) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "citext"
enable_extension "uuid-ossp"

create_table "actions", force: :cascade do |t|
t.integer "person_id", null: false
t.integer "activity_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "person_id", null: false
t.integer "activity_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "utm_source"
t.string "utm_medium"
t.string "utm_campaign"
t.string "source_url"
t.integer "donation_amount_in_cents"
t.integer "donation_page_id"
t.integer "strike_amount_in_cents"
t.integer "privacy_status", default: 0
end

add_index "actions", ["activity_id"], name: "index_actions_on_activity_id", using: :btree
add_index "actions", ["donation_amount_in_cents"], name: "index_actions_on_donation_amount_in_cents", using: :btree
add_index "actions", ["donation_page_id"], name: "index_actions_on_donation_page_id", using: :btree
add_index "actions", ["person_id", "activity_id"], name: "index_actions_on_person_id_and_activity_id", using: :btree
add_index "actions", ["person_id"], name: "index_actions_on_person_id", using: :btree
add_index "actions", ["privacy_status"], name: "index_actions_on_privacy_status", using: :btree

create_table "activities", force: :cascade do |t|
t.string "name"
Expand Down
3 changes: 3 additions & 0 deletions spec/models/action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
require 'rails_helper'

describe Action do
it { should define_enum_for(:privacy_status).with([:visible, :hidden]) }
it { should validate_presence_of(:person) }
it { should validate_presence_of(:activity) }

describe 'scopes' do
before(:all) do
Expand Down

0 comments on commit 7cf617f

Please sign in to comment.