Skip to content

Commit

Permalink
Added the twitter handle and github userid profile attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyhelbling committed Mar 19, 2016
1 parent d464cfd commit e662dc3
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 28 deletions.
3 changes: 3 additions & 0 deletions src/app/assets/stylesheets/participant.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.row + .bio {
margin: 20px 10px;
}
7 changes: 5 additions & 2 deletions src/app/assets/stylesheets/shared.css.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$white: #fff;
$grey: rgb(209, 217, 220);
$minnebar-purple: #414D87;

body {
background-color: #fff;
Expand Down Expand Up @@ -40,7 +41,7 @@ a {
img {
border: none;
}
color: #0000FF;
color: $minnebar-purple;
}

.clear {
Expand Down Expand Up @@ -219,4 +220,6 @@ h4 {
font-size: 1.1em;
}


.smaller {
font-size: 0.8em;
}
1 change: 1 addition & 0 deletions src/app/assets/stylesheets/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ $screen-xs-max: ($screen-sm-min - 1) !default;
//** Text muted color
$text-muted: $gray-light !default;

$minnebar-purple: #414D87;

4 changes: 3 additions & 1 deletion src/app/controllers/participants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def create
private

def participant_params
params.require(controller_name.singularize).permit(:name, :email, :password, :bio)
params.require(controller_name.singularize).permit(:name, :email, :password,
:bio, :github_profile_username,
:twitter_handle)
end

def verify_owner
Expand Down
4 changes: 4 additions & 0 deletions src/app/models/participant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def attending_session?(session)
sessions_attending.include?(session)
end

def github_profile_url
"https://github.com/#{self.github_profile_username}"
end

end


2 changes: 2 additions & 0 deletions src/app/views/participants/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<%= f.inputs do %>
<%= f.input :name, :label => 'Your name', :hint => "Please use your real name. This will be used in our printed materials." %>
<%= f.input :email, :label => 'Your email', :hint => "Please use a real email address. We need this to contact you about your presentation." %>
<%= f.input :github_profile_username, :label => 'Your GitHub username' %>
<%= f.input :twitter_handle, :label => 'Your Twitter handle' %>
<%= f.input :bio, :hint => 'You can use <a href="http://daringfireball.net/projects/markdown/syntax">Markdown</a> syntax here. Examples: <strong>**bold**</strong>, <em>*italic*</em>, [link](http://example.com)'.html_safe %>
<% end %>
Expand Down
32 changes: 26 additions & 6 deletions src/app/views/participants/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,37 @@
<% content_for :edit do %>
<% edit(@participant) do %>
(This is you! <%= link_to 'Edit your profile', edit_participant_path(@participant) %>.)
<span><%= link_to 'edit your profile', edit_participant_path(@participant), class: "smaller" %></span>
<% end %>
<% end %>

<h3>Bio</h3>
<div class="row">
<% if @participant.github_profile_username.present? %>
<div class="grid_2 column">
<h4>GitHub:</h4>
<div><%= link_to @participant.github_profile_username, @participant.github_profile_url, target: "blank" %></div>
</div>
<% end %>
<% if @participant.bio.blank? %>
<p>This user hasn't yet added a bio.</p>
<% end %>
<% if @participant.twitter_handle.present? %>
<div class="grid_3 column">
<h4>Twitter:</h4>
<div>@<%= @participant.twitter_handle %></div>
</div>
<% end %>
</div>

<div class="row bio">
<h4>Bio</h4>

<% if @participant.bio.blank? %>
<p>This user hasn't yet added a bio.</p>
<% else %>
<%= markdown @participant.bio %>
<% end %>
</div>

<%= markdown @participant.bio %>
<hr/>

<div class="column grid_5">
<h3>Presenting Sessions</h3>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class AddMoreAttributesToParticipant < ActiveRecord::Migration
def change
add_column :participants, :github_profile_username, :string #github username
add_column :participants, :github_og_image, :string # github avatar
add_column :participants, :github_og_url, :string # github user profile url
add_column :participants, :twitter_handle, :string
end
end
24 changes: 14 additions & 10 deletions src/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150920192518) do
ActiveRecord::Schema.define(version: 20160319173736) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -52,14 +52,18 @@
end

create_table "participants", force: :cascade do |t|
t.string "name", limit: 255
t.string "email", limit: 255
t.string "name", limit: 255
t.string "email", limit: 255
t.text "bio"
t.datetime "created_at"
t.datetime "updated_at"
t.string "crypted_password", limit: 255
t.string "persistence_token", limit: 255
t.string "perishable_token", limit: 255, default: "", null: false
t.string "crypted_password", limit: 255
t.string "persistence_token", limit: 255
t.string "perishable_token", limit: 255, default: "", null: false
t.string "github_profile_username"
t.string "github_og_image"
t.string "github_og_url"
t.string "twitter_handle"
end

add_index "participants", ["email"], name: "index_participants_on_email", unique: true, using: :btree
Expand All @@ -83,12 +87,12 @@
add_index "presenter_timeslot_restrictions", ["timeslot_id", "participant_id"], name: "present_timeslot_participant_unique", unique: true, using: :btree

create_table "rooms", force: :cascade do |t|
t.integer "event_id", null: false
t.string "name", limit: 255, null: false
t.integer "event_id", null: false
t.string "name", limit: 255, null: false
t.integer "capacity"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "schedulable", default: true
t.boolean "schedulable", default: true
end

create_table "sessions", force: :cascade do |t|
Expand Down Expand Up @@ -116,7 +120,7 @@
add_index "settings", ["current_event_id"], name: "index_settings_on_current_event_id", using: :btree

create_table "timeslots", force: :cascade do |t|
t.integer "event_id", null: false
t.integer "event_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "starts_at"
Expand Down
3 changes: 2 additions & 1 deletion src/lib/tasks/app.rake
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,10 @@ namespace :app do
100.times do
participant = Participant.new
participant.name = FFaker::Name.name
participant.email = FFaker::Internet.email
participant.email = FFaker::Internet.safe_email
participant.password = 'standard'
participant.bio = FFaker::Lorem.paragraph if [true, false].sample
participant.twitter_handle = Faker::Internet.user_name(participant.name) if [true, false].sample
participant.save!
progress.increment
end
Expand Down
38 changes: 30 additions & 8 deletions src/spec/controllers/participants_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@

describe "#create" do
it "should be successful" do
post :create, participant: { name: 'Alan Turing', email: 'tapewriter@example.org', password: 'infinite-memory' }
post :create, participant: { name: 'Alan Turing',
email: 'tapewriter@example.org',
password: 'infinite-memory'
}
expect(response).to redirect_to root_path
expect(flash[:notice]).to eq "Thanks for registering an account. You may now create sessions and mark sessions you'd like to attend."
end
Expand All @@ -39,15 +42,21 @@
end

context "when the logged in user operates on someone elses record" do
let(:luke) { create(:luke) }
before do
activate_authlogic
ParticipantSession.create(luke)
end

describe "#edit" do
it "should be successful" do
it "should be not be allowed" do
get :edit, id: participant
expect(response).to be_redirect
end
end

describe "#update" do
it "should be successful" do
it "will not be allowed" do
put :update, id: participant, participant: { name: 'Alan Kay' }
expect(response).to be_redirect
expect(participant.reload.name).to_not eq 'Alan Kay'
Expand All @@ -58,22 +67,35 @@
context "when the logged in user operates on their own record" do
before do
activate_authlogic
ParticipantSession.create(participant)
ParticipantSession.create(joe)
end
let(:joe) { create(:joe) }

describe "#edit" do
it "should be successful" do
get :edit, id: participant
get :edit, id: joe
expect(response).to be_successful
expect(assigns(:participant)).to be_kind_of Participant
end
end

describe "#update" do
it "should be successful" do
put :update, id: participant, participant: { name: 'Alan Kay' }
expect(response).to redirect_to participant
expect(participant.reload.name).to eq 'Alan Kay'
put :update, id: joe, participant: { name: 'schmoe, joe' }
expect(response).to redirect_to joe
expect(joe.reload.name).to eq 'schmoe, joe'
end

describe "more attributes are not required" do
it "should be successful" do
put :update, id: joe, participant: {
twitter_handle: 'schmoe',
github_profile_username: 'jschmoe'
}
expect(response).to be_redirect
expect(joe.reload.twitter_handle).to eq 'schmoe'
expect(joe.github_profile_username).to eq 'jschmoe'
end
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions src/spec/factories/participant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
factory :luke do
email "look@recursion.org"
name 'Luke Francl'
github_profile_username "look"
github_og_image "https://avatars1.githubusercontent.com/u/10186?v=3&s=400"
github_og_url "https://github.com/look"
twitter_handle "lof"
end
end
end
28 changes: 28 additions & 0 deletions src/spec/features/manage_your_profile_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require "spec_helper"

feature "Manage a user profile" do

context "As an authenticated user" do
let(:joe) { create(:joe) }
background do
create(:event)
sign_in_user(joe)
expect(page).to have_content "You're logged in. Welcome back."
end

scenario "I can updated my profile attributes" do
click_link "Welcome Joe Schmoe"
fill_in 'Your GitHub username', with: "JoeSchmoeGithubUsername"
fill_in 'Your Twitter handle', with: "JoeSchmoeTwitterHandle"
bio = FFaker::HipsterIpsum.paragraph(3)
fill_in 'Bio', with: bio
click_button "Update Participant"

expect(page).to have_content "JoeSchmoeGithubUsername"
expect(page).to have_content "JoeSchmoeTwitterHandle"
expect(page).to have_content bio
end
end

end

8 changes: 8 additions & 0 deletions src/spec/models/participant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

describe Participant do

describe "github profile url" do
let(:luke) { create(:luke) }

it "can be constructed with a github username" do
expect(luke.github_profile_url).to eq "https://github.com/look"
end
end

describe "timeslot restrictions" do
let(:event) { create(:event) }
let!(:time1) { create(:timeslot_1, event: event) }
Expand Down

0 comments on commit e662dc3

Please sign in to comment.