Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNOE-406] Added logic to load delisted apps if already in dashboard #644

Open
wants to merge 6 commits into
base: 3.3
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end
# json.connector_version app_instance.oauth_keys[:version]
# end

app_instance.app.tap do |a|
@apps[app_instance.app_id].first.tap do |a|
json.app_id a.id
json.app_name a.name
json.app_nid a.nid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def index
i.owner = parent_organization
can?(:access,i)
end
ids = @app_instances.collect{ |i| i.app_id }
@apps = MnoEnterprise::App.where('id.in' => ids, unscoped: params[:unscoped].present?).group_by(&:id)
end

# POST /mnoe/jpi/v1/organization/1/app_instances
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ module MnoEnterprise
let(:organization) { build(:organization) }
before { allow_any_instance_of(MnoEnterprise::User).to receive(:organizations).and_return([organization]) }

let(:app) { build(:app) }

describe 'GET #index' do
let(:app_instance) { build(:app_instance, status: "running") }
let(:app_instance) { build(:app_instance, under_free_trial: false) }
Expand All @@ -30,6 +32,11 @@ module MnoEnterprise
allow(app_instances).to receive(:active).and_return(app_instances)
# Updated since last tick
allow(app_instances).to receive(:where).and_return([app_instance])

allow(app_instance).to receive(:app_id).and_return(app.id)

api_stub_for(get: "/apps?filter[id.in][]=#{app.id}&filter[unscoped]=false", response: from_api([app]))
api_stub_for(get: "/apps?filter[id.in]&filter[unscoped]=false", response: from_api(nil))
end

before { sign_in user }
Expand All @@ -47,6 +54,15 @@ module MnoEnterprise
end
end

context 'with unscoped data' do
before { api_stub_for(get: "/apps?filter[id.in][]=#{app.id}&filter[unscoped]=true", response: from_api([app])) }
subject { get :index, organization_id: organization.id, timestamp: timestamp, unscoped: true }

it 'retrieved the app instance with the app' do
subject
end
end

context 'with timestamp' do
let(:timestamp) { Time.current.to_i }

Expand Down