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

Filter env-variables group by project #3595

Merged
merged 1 commit into from
Nov 2, 2019
Merged
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 @@ -5,6 +5,12 @@ class EnvironmentVariableGroupsController < ApplicationController

def index
@groups = EnvironmentVariableGroup.all.includes(:environment_variables)

if project_id = params[:project_id].presence
@groups = @groups.joins(:project_environment_variable_groups).
where("project_environment_variable_groups.project_id = ?", project_id)
end

respond_to do |format|
format.html
format.json do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ def self.it_destroys
project = JSON.parse(response.body)
project.keys.must_include "environment_variables"
end

it "filters by project" do
ProjectEnvironmentVariableGroup.create!(environment_variable_group: other_env_group, project: other_project)
get :index, params: {project_id: other_project.id, format: :json}
assert_response :success
json_response = JSON.parse response.body
first_group = json_response['environment_variable_groups'].first

json_response['environment_variable_groups'].count.must_equal 1
first_group.keys.must_include "name"
first_group.keys.must_include "variable_names"
first_group['name'].must_equal other_env_group.name
first_group['variable_names'].must_equal ["X", "Y"]
end
end

describe "#show" do
Expand Down