-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
enable disable all agents within a scenario #1506
Changes from all commits
2e2be8d
1529c6f
c314225
b7684b9
dfbbf6b
90fcd6f
c0aaa19
a644c92
a673743
fae6c10
a146fc8
5895e76
fbc5e62
332106c
4a3bb4b
02200f3
6553c92
3e53dd8
b1a1c49
7456400
ab5a529
39d38e9
8655fe1
9e85f8e
ea48a9b
a2ca396
95ad506
6651006
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class @ScenarioShowPage | ||
constructor:() -> | ||
@changeModalText() | ||
|
||
changeModalText: () -> | ||
$('#disable-all').click -> | ||
$('#enable-disable-agents .modal-body').text 'Would you like to disable all agents?' | ||
$('#scenario-disabled-value').val 'true' | ||
$('#enable-all').click -> | ||
$('#enable-disable-agents .modal-body').text 'Would you like to enable all agents?' | ||
$('#scenario-disabled-value').val 'false' | ||
|
||
$ -> | ||
Utils.registerPage(ScenarioShowPage, forPathsMatching: /^scenarios/) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div id="enable-disable-agents" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="enableAgentLabel" aria-hidden="true"> | ||
<div class="modal-dialog modal-sm"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> | ||
<h4 class="modal-title">Confirm</h4> | ||
</div> | ||
<div class="modal-body"> | ||
</div> | ||
<div class="modal-footer"> | ||
<%= form_for(scenario, as: :scenario, url: enable_or_disable_all_agents_scenario_path(scenario), method: 'PUT') do |f| %> | ||
<%= f.hidden_field :disabled, value: '', id: "scenario-disabled-value" %> | ||
<%= f.button 'No', class: 'btn btn-default', 'data-dismiss' => 'modal' %> | ||
<%= f.submit 'Yes', class: 'btn btn-primary' %> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,6 +140,15 @@ def valid_attributes(options = {}) | |
end | ||
end | ||
|
||
describe 'PUT enable_or_disable_all_agents' do | ||
it 'updates disabled on all agents in a scenario for the current user' do | ||
@params = {"scenario"=>{"disabled"=>"true"}, "commit"=>"Yes", "id"=> scenarios(:bob_weather).id} | ||
put :enable_or_disable_all_agents, @params | ||
expect(agents(:bob_rain_notifier_agent).disabled).to eq(true) | ||
expect(response).to redirect_to(scenario_path(scenarios(:bob_weather))) | ||
end | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure why this test isn't passing. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Never mind I fixed it. I just need to modify params a bit and is straight from my log. |
||
describe "DELETE destroy" do | ||
it "destroys only Scenarios owned by the current user" do | ||
expect { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I whittled this down to a bit because of rubocop assignment branch error (method does too much). I think this is more akin to the
destroy
method below it than theupdate
method above it. The likelihood that this will fail is on the low side.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry about the code complexity offenses of rubocop too much, in my suggestion #1505 I disabled them completely because the default values are really low and almost impossible to achieve in a rails project (at least in my experience) 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if we are going to use rubocop from now on to check the code style. I actually grab the yml file from your pr. I will put what I had back in later.