forked from davesloan/restful_api_authentication
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Closed Issue davesloan#7 - Option to use a different ActiveRecord class than RestClient * This update involves a lot of changes to a lot of files, but the functionality remains the same. The change was to rename RestClient to RestAppClient and rest_client to rest_client. This avoids a conflict with the popular rest-client gem that uses the same RestClient class name.
- Loading branch information
1 parent
1ebfead
commit 346be9b
Showing
17 changed files
with
97 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...n/install/templates/create_rest_client.rb → ...stall/templates/create_rest_app_client.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tication/install/templates/rest_client.rb → ...tion/install/templates/rest_app_client.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/dummy/app/models/rest_client.rb → test/dummy/app/models/rest_app_client.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...rate/20120423195432_create_rest_client.rb → .../20120423195432_create_rest_app_client.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
test/dummy/spec/factories/rest_clients.rb → .../dummy/spec/factories/rest_app_clients.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
FactoryGirl.define do | ||
factory :rest_client, :class => RestClient do | ||
factory :rest_app_client, :class => RestAppClient do | ||
name Random.alphanumeric | ||
description Random.paragraphs(1) | ||
api_key "69704d90-4b77-012f-c334-68a86d3dfd02" | ||
secret "1e5483d9c6ddbe2f26eecf444ec7a976b2836ab17a209a0940f4dfdee1b3bc93" | ||
is_master true | ||
end | ||
factory :alternative_rest_client, :class => RestClient do | ||
factory :alternative_rest_app_client, :class => RestAppClient do | ||
name Random.alphanumeric | ||
description Random.paragraphs(1) | ||
end | ||
factory :rest_client_without_name, :class => RestClient do | ||
factory :rest_app_client_without_name, :class => RestAppClient do | ||
name nil | ||
description Random.paragraphs(1) | ||
end | ||
factory :rest_client_without_description, :class => RestClient do | ||
factory :rest_app_client_without_description, :class => RestAppClient do | ||
name Random.alphanumeric | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'spec_helper' | ||
|
||
describe RestAppClient do | ||
|
||
it "should be able to generate a new api key upon request" do | ||
rest_app_client = RestAppClient.new | ||
rest_app_client.gen_api_key | ||
rest_app_client.api_key.should_not be_nil | ||
end | ||
|
||
it "should be able to generate a new secret upon request" do | ||
rest_app_client = RestAppClient.new | ||
rest_app_client.gen_secret | ||
rest_app_client.secret.should_not be_nil | ||
end | ||
|
||
it "should save a valid client" do | ||
RestAppClient.should have(0).records | ||
rest_app_client = FactoryGirl.build :rest_app_client | ||
rest_app_client.save | ||
RestAppClient.should have(1).record | ||
end | ||
|
||
it "should not allow an empty name on create" do | ||
rest_app_client = FactoryGirl.build :rest_app_client | ||
rest_app_client.name = nil | ||
rest_app_client.should_not be_valid | ||
end | ||
|
||
it "should not allow an empty description on create" do | ||
rest_app_client = FactoryGirl.build :rest_app_client | ||
rest_app_client.description = nil | ||
rest_app_client.should_not be_valid | ||
end | ||
|
||
it "should enforce unique api keys" do | ||
rest_app_client1 = FactoryGirl.build :rest_app_client | ||
rest_app_client1.save | ||
rest_app_client2 = FactoryGirl.build :rest_app_client | ||
rest_app_client2.should_not be_valid | ||
end | ||
|
||
it "should set is_master to false if not explicitly set" do | ||
rest_app_client = RestAppClient.new(:name => "Test", :description => "Test") | ||
rest_app_client.should be_valid | ||
rest_app_client.is_master.should == false | ||
end | ||
|
||
end |
This file was deleted.
Oops, something went wrong.