Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 22, 2017. It is now read-only.

Commit

Permalink
Merge pull request #238 from bitzesty/chunked-upgrade-gems
Browse files Browse the repository at this point in the history
upgrade sso gems
  • Loading branch information
matthewford committed Apr 14, 2015
2 parents 506aaa2 + 81a3373 commit bba4439
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Expand Up @@ -16,8 +16,8 @@ gem "elasticsearch-extensions", "~> 0.0"
gem "yajl-ruby", "~> 1.2", require: "yajl"
gem "dalli", "~> 2.7.2"
gem "builder", "~> 3.2"
gem "plek", "~> 1.8"
gem "gds-sso", "9.3.0"
gem "plek", "~> 1.10"
gem "gds-sso", "~> 10.0"

gem "unicorn", "~> 4.8"
gem "curb", "0.8.6"
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Expand Up @@ -108,7 +108,7 @@ GEM
ffi (1.9.6)
forgery (0.6.0)
formatador (0.2.5)
gds-sso (9.3.0)
gds-sso (10.0.0)
multi_json (~> 1.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
Expand Down Expand Up @@ -360,7 +360,7 @@ DEPENDENCIES
factory_girl_rails
fakefs
forgery
gds-sso (= 9.3.0)
gds-sso (~> 10.0)
guard-rspec
hashie (~> 3.4)
json_expressions
Expand All @@ -370,7 +370,7 @@ DEPENDENCIES
mysql2 (~> 0.3)
newrelic_rpm
nokogiri (~> 1.6)
plek (~> 1.8)
plek (~> 1.10)
pry-nav
pry-rails
rabl (~> 0.11)
Expand Down
8 changes: 8 additions & 0 deletions app/models/user.rb
Expand Up @@ -30,6 +30,10 @@ def self.find_by_uid(uid)
find(uid: uid)
end

def self.create!(attrs)
create(attrs)
end

def gds_editor?
has_permission?(Permissions::GDS_EDITOR)
end
Expand All @@ -45,4 +49,8 @@ def remotely_signed_out?
def update_attribute(attribute, value)
update({ attribute => value })
end

def update_attributes(attributes)
update(attributes)
end
end
2 changes: 1 addition & 1 deletion config/initializers/gds-sso.rb
Expand Up @@ -2,5 +2,5 @@
config.user_model = "User"
config.oauth_id = ENV['TRADE_TARIFF_OAUTH_ID'] || "abcdefgh12345678tariffapi"
config.oauth_secret = ENV['TRADE_TARIFF_OAUTH_SECRET'] || "secret"
config.oauth_root_url = Plek.current.find("signon")
config.oauth_root_url = Plek.find("signon")
end
13 changes: 13 additions & 0 deletions db/migrate/20150406165721_add_disabled_to_user.rb
@@ -0,0 +1,13 @@
Sequel.migration do
up do
alter_table :users do
add_column :disabled, FalseClass, default: false
end
end

down do
alter_table :users do
drop_column :disabled
end
end
end
54 changes: 54 additions & 0 deletions spec/models/user_spec.rb
@@ -0,0 +1,54 @@
require "spec_helper"
require "gds-sso/lint/user_spec"

describe User do
describe "gds-sso" do
it_behaves_like "a gds-sso user class"
end

describe "#update_attributes" do
let!(:user) { create :user }
let(:attrs) {
attributes_for :user
}

before {
user.update_attributes(attrs)
user.reload
}

it {
expect(user.name).to eq(attrs[:name])
expect(user.email).to eq(attrs[:email])
}
end

describe "#create!" do
describe "valid" do
let(:attrs) {
attributes_for :user
}

it {
expect {
User.create!(attrs)
}.to change{ User.count }.by(1)
}
end

describe "invalid" do
let!(:user) { create :user }
let(:attrs) {
attributes_for(:user).merge(
id: user.id
)
}

it {
expect {
User.create!(attrs)
}.to raise_error(Sequel::Error)
}
end
end
end

0 comments on commit bba4439

Please sign in to comment.