Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/controllers/beta_signups_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class BetaSignupsController < ApplicationController
def create
bsu = BetaSignup.new
bsu.user = current_user

respond_to do |format|
format.json { render json: bsu.save.to_json }
end
end
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
resources :projects
resources :favorites
resources :events
resources :beta_signups, only: [:create]

# Static content
get '/about', controller: 'home', action: 'about'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeBetaSignupsUserIdToBePresent < ActiveRecord::Migration
def change
change_column :beta_signups, :user_id, :integer, null: false
end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20150227190642) do
ActiveRecord::Schema.define(:version => 20150310143949) do

create_table "active_admin_comments", :force => true do |t|
t.string "namespace"
Expand All @@ -28,7 +28,7 @@
add_index "active_admin_comments", ["resource_type", "resource_id"], :name => "index_active_admin_comments_on_resource_type_and_resource_id"

create_table "beta_signups", :force => true do |t|
t.integer "user_id"
t.integer "user_id", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
Expand Down
21 changes: 21 additions & 0 deletions spec/controllers/beta_signups_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "spec_helper"

describe BetaSignupsController do
include Devise::TestHelpers

describe "POST #create" do
let(:user) { create(:user) }
before { sign_in user }

it "is successful" do
post :create, format: :json
expect(response).to be_success
end

it "saves a new beta_signup to the database" do
expect do
post :create, format: :json
end.to change(BetaSignup, :count).by(1)
end
end
end