Commit 1607581e authored by Gabriel Mazetto's avatar Gabriel Mazetto

Only create an OAuth Application for secondary nodes

parent 1c62f762
......@@ -73,8 +73,13 @@ class GeoNode < ActiveRecord::Base
def update_dependents_attributes
self.geo_node_key.title = "Geo node: #{self.url}" if self.geo_node_key
self.oauth_application.name = "Geo node: #{self.url}" if self.geo_node_key
self.oauth_application.redirect_uri = oauth_callback_url
if self.primary?
self.oauth_application = nil
else
self.oauth_application.name = "Geo node: #{self.url}" if self.geo_node_key
self.oauth_application.redirect_uri = oauth_callback_url
end
end
def validate(record)
......
......@@ -68,19 +68,26 @@ describe GeoNode, type: :model do
end
context 'on create' do
before(:each) do
subject.geo_node_key_attributes = geo_node_key_attributes
subject.save!
end
it 'saves a corresponding key' do
subject.save!
expect(subject.geo_node_key).to be_persisted
end
it 'saves a corresponding oauth application' do
it 'saves a corresponding oauth application if it is a secondary node' do
subject.save!
expect(subject.oauth_application).to be_persisted
end
it 'has no oauth_application if it is a primary node' do
subject.primary=true
subject.save!
expect(subject.oauth_application).not_to be_present
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment